diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 802dc9f..33406b0 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -5,6 +5,17 @@ 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.34] - 2026-03-18 + +### Fixed +- **Web UI**: Fixed URL resolution issue - scan now uses relative URL 'scan' instead of '/scan' to work correctly with Home Assistant ingress. +- **Web UI**: Improved error handling for non-JSON responses and malformed API responses. +- **Web UI**: Added better debugging for JSON parsing errors. + +### Changed +- **Web UI**: Updated scan fetch call to match other API calls in the codebase. +- **Web UI**: Enhanced error messages to include raw response text when JSON parsing fails. + ## [0.1.33] - 2026-03-18 ### Fixed diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index 04dd450..d6ca277 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.33" +version: "0.1.34" 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/api.py b/fichero_printer/fichero/api.py index 1e52f5e..c55584c 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -77,7 +77,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001 app = FastAPI( title="Fichero Printer API", description="REST API for the Fichero D11s (AiYin) thermal label printer.", - version = "0.1.33", + version = "0.1.34", lifespan=lifespan, docs_url=None, redoc_url=None, @@ -153,14 +153,25 @@ def _ui_html() -> str: console.log('Starting scan request...'); try { - const response = await fetch('/scan'); + const response = await fetch('scan'); if (!response.ok) { - const error = await response.json(); - throw new Error(error.detail || `HTTP error! status: ${response.status}`); + try { + const error = await response.json(); + throw new Error(error.detail || `HTTP error! status: ${response.status}`); + } catch (e) { + const text = await response.text(); + throw new Error(`HTTP error! status: ${response.status}, response: ${text}`); + } } - const devices = await response.json(); + let devices; + try { + devices = await response.json(); + } catch (e) { + const text = await response.text(); + throw new Error(`Invalid JSON response: ${text}`); + } if (devices.length === 0) { resultsEl.textContent = '📡 No BLE devices found.\n\nTroubleshooting tips:\n- Make sure your printer is powered on\n- Ensure Bluetooth is enabled on this device\n- Bring the printer closer (within 5 meters)\n- Try restarting the printer'; diff --git a/pyproject.toml b/pyproject.toml index 7c779c7..b71aded 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "fichero-printer" -version = "0.1.33" +version = "0.1.34" description = "Web GUI, Python CLI, and protocol documentation for the Fichero D11s thermal label printer." readme = "README.md" requires-python = ">=3.10"