#!/usr/bin/with-contenv bashio # shellcheck shell=bash set -e declare port declare ble_address declare transport declare channel port=$(bashio::config 'port') transport=$(bashio::config 'transport') channel=$(bashio::config 'channel') # Pass connection settings to the Python module via environment variables. # The module reads these at import time, so they must be exported before uvicorn # imports fichero.api. export FICHERO_TRANSPORT="${transport}" export FICHERO_CHANNEL="${channel}" ble_address=$(bashio::config 'ble_address') if [ -n "${ble_address}" ]; then export FICHERO_ADDR="${ble_address}" bashio::log.info "Using fixed Bluetooth address: ${ble_address}" else bashio::log.info "No address configured – will auto-scan for printer on first request." fi bashio::log.info "Starting Fichero Printer API on 0.0.0.0:${port} (transport: ${transport})..." exec uvicorn fichero.api:app --host 0.0.0.0 --port "${port}"