diff --git a/CHANGELOG.md b/CHANGELOG.md index 5500feb..b404860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project are documented in this file. The format is based on Keep a Changelog and this project uses Semantic Versioning. +## [0.1.9] - 2026-03-07 + +### Added +- Added add-on-local changelog at `fichero_printer/CHANGELOG.md` so Home Assistant can display release notes in the add-on UI. + +### Changed +- Improved Classic Bluetooth connect logic by trying fallback RFCOMM channels (1-3 plus configured channel) before failing. + ## [0.1.8] - 2026-03-07 ### Added diff --git a/fichero/printer.py b/fichero/printer.py index 6a9da82..2f6644f 100644 --- a/fichero/printer.py +++ b/fichero/printer.py @@ -384,10 +384,25 @@ async def connect( if classic: if not address: raise PrinterError("--address is required for Classic Bluetooth (no scanning)") - async with RFCOMMClient(address, channel) as client: - pc = PrinterClient(client) - await pc.start() - yield pc + # D11s variants are commonly exposed on channel 1 or 3. + candidates = [channel, 1, 2, 3] + channels = [ch for i, ch in enumerate(candidates) if ch > 0 and ch not in candidates[:i]] + last_exc: Exception | None = None + for ch in channels: + try: + async with RFCOMMClient(address, ch) as client: + pc = PrinterClient(client) + await pc.start() + yield pc + return + except (PrinterError, PrinterTimeout) as exc: + last_exc = exc + if last_exc is not None: + raise PrinterError( + f"Classic Bluetooth connection failed for '{address}'. " + f"Tried channels: {channels}. Last error: {last_exc}" + ) from last_exc + raise PrinterError(f"Classic Bluetooth connection failed for '{address}'.") else: addr = address or await find_printer() try: diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md new file mode 100644 index 0000000..8438071 --- /dev/null +++ b/fichero_printer/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +## 0.1.9 + +- Added add-on local changelog file so Home Assistant can display release notes. +- Improved Classic Bluetooth RFCOMM connection robustness by trying fallback channels (1-3 plus configured channel). + +## 0.1.8 + +- Added Home Assistant web print interface on `/` with status/info/text/image actions. + +## 0.1.7 + +- Fixed ingress Swagger OpenAPI loading behind Home Assistant. +- Enabled `full_access` for stricter hosts blocking RFCOMM sockets. + +## 0.1.6 + +- Added root changelog and release policy. + +## 0.1.5 + +- Added `NET_RAW` capability for Classic Bluetooth sockets. + +## 0.1.4 + +- Fixed RFCOMM connect path under uvloop. + +## 0.1.3 + +- Added ingress/webui metadata updates. + diff --git a/fichero_printer/DOCS.md b/fichero_printer/DOCS.md index 82e51b5..afeb4dc 100644 --- a/fichero_printer/DOCS.md +++ b/fichero_printer/DOCS.md @@ -22,7 +22,7 @@ direkt aus Home Assistant-Automationen, Skripten oder externen Anwendungen. | `port` | `8765` | Port des REST-API-Servers (auch im „Port-Mapping" oben anpassen) | | `ble_address` | _(leer)_ | Feste BLE-Adresse des Druckers (z.B. `AA:BB:CC:DD:EE:FF`). Leer lassen für automatischen Scan. | | `transport` | `ble` | Verbindungsart: `ble` (Bluetooth Low Energy) oder `classic` (RFCOMM) | -| `channel` | `1` | RFCOMM-Kanal – nur relevant bei `transport: classic` | +| `channel` | `1` | RFCOMM-Kanal – nur relevant bei `transport: classic` (bei Fehlern werden zusätzlich typische Kanäle getestet) | ## Verwendung diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index 4edbadc..b8e3879 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.8" +version: "0.1.9" slug: "fichero_printer" description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth" url: "https://git.leuschner.dev/Tobias/Fichero" diff --git a/fichero_printer/fichero/printer.py b/fichero_printer/fichero/printer.py index 6a9da82..2f6644f 100644 --- a/fichero_printer/fichero/printer.py +++ b/fichero_printer/fichero/printer.py @@ -384,10 +384,25 @@ async def connect( if classic: if not address: raise PrinterError("--address is required for Classic Bluetooth (no scanning)") - async with RFCOMMClient(address, channel) as client: - pc = PrinterClient(client) - await pc.start() - yield pc + # D11s variants are commonly exposed on channel 1 or 3. + candidates = [channel, 1, 2, 3] + channels = [ch for i, ch in enumerate(candidates) if ch > 0 and ch not in candidates[:i]] + last_exc: Exception | None = None + for ch in channels: + try: + async with RFCOMMClient(address, ch) as client: + pc = PrinterClient(client) + await pc.start() + yield pc + return + except (PrinterError, PrinterTimeout) as exc: + last_exc = exc + if last_exc is not None: + raise PrinterError( + f"Classic Bluetooth connection failed for '{address}'. " + f"Tried channels: {channels}. Last error: {last_exc}" + ) from last_exc + raise PrinterError(f"Classic Bluetooth connection failed for '{address}'.") else: addr = address or await find_printer() try: diff --git a/pyproject.toml b/pyproject.toml index b881a46..bf4ef25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fichero-printer" -version = "0.1.8" +version = "0.1.9" description = "Fichero D11s thermal label printer - BLE CLI tool" requires-python = ">=3.10" dependencies = [