# Changelog 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.43] - 2026-03-18 ### Fixed - **Unused Import**: Removed unused render_label import causing ImportError - **Circular Import**: Maintained fix from v0.1.42 - **Module Structure**: Cleaned up all dependencies ### Added - **Version**: 0.1.43 for Home Assistant recognition - **Documentation**: Updated CHANGELOG with all fixes - **Stability**: All previous improvements maintained ### Changed - **printer.py**: Removed unused import - **Version**: Updated to 0.1.43 - **Dependencies**: Clean module structure ### Improved - **Reliability**: No more ImportErrors - **Maintainability**: Cleaner codebase - **Compatibility**: Ready for Home Assistant deployment ## [0.1.42] - 2026-03-18 ### Fixed - **Circular Import**: Resolved circular import between printer.py and imaging.py - **Module Structure**: Cleaned up module dependencies - **Simplified Connection Logic**: Maintained from v0.1.41 ### Added - **PRINTHEAD_PX Constant**: Moved to imaging.py to avoid circular imports - **Clearer Architecture**: Better separation of concerns between modules - **Stable BLE Connections**: Direct BLE connections without intermediate cache operations ### Changed - **Module Organization**: imaging.py now contains printer constants - **Import Structure**: Removed problematic cross-imports - **Code Structure**: Simplified architecture focusing on reliability ### Improved - **Reliability**: More stable module loading - **Debuggability**: Cleaner module structure - **Maintainability**: Easier to understand dependencies ## [0.1.41] - 2026-03-18 ### Fixed - **Simplified Connection Logic**: Reverted to simpler, more reliable connection approach - **Removed Complex Recovery**: Eliminated overly aggressive Bluetooth stack manipulation - **Stable BLE Connections**: Direct BLE connections without intermediate cache operations ### Added - **Simplified Printer Client**: Streamlined connection logic similar to original working code - **Basic Channel Testing**: Classic Bluetooth tests channels 1, 2, 3 sequentially - **Direct BLE Connection**: Clean BLE connection without complex recovery attempts ### Changed - **Connection Strategy**: Back to basics - simple, direct connections like original code - **Error Handling**: Clear, actionable error messages without complex recovery - **Code Structure**: Simplified architecture focusing on reliability over features ### Improved - **Reliability**: More stable connections by removing complex recovery logic - **Debuggability**: Simpler code is easier to debug and maintain - **Performance**: Faster connections without unnecessary retry logic ## [0.1.40] - 2026-03-18 ### Fixed - **Configuration Structure**: Corrected Home Assistant add-on config.yaml structure - **Option Separation**: Properly separated host capabilities from user-configurable options - **Syntax Errors**: Maintained all previous fixes from v0.1.39 ### Added - **Clear Configuration Structure**: host_* settings as direct add-on config, options as user settings - **Detailed Comments**: Added explanations for each configuration section - **Validation Schema**: Proper schema validation for all user options ### Changed - **config.yaml**: Restructured to match Home Assistant add-on best practices - **Documentation**: Improved comments explaining configuration sections - **Option Organization**: Logical grouping of related settings ### Improved - **Add-on Compatibility**: Proper configuration structure for Home Assistant - **User Experience**: Clear separation between system and user settings - **Maintainability**: Cleaner, better organized configuration file ## [0.1.39] - 2026-03-18 ### Fixed - **Syntax Error**: Fixed unterminated f-string in Bluetooth reset commands - **Persistent BLE Errors**: Added comprehensive Bluetooth stack reset for `br-connection-not-supported` errors - **Connection Recovery**: Enhanced automatic recovery with full Bluetooth service restart - **Classic Bluetooth**: Maintained fixes for `[Errno 12] Out of memory` errors ### Added - **Comprehensive Bluetooth Reset**: Automatic full stack reset (cache clear + service restart) when BLE fails persistently - **Final Recovery Attempt**: One last connection attempt after full stack reset - **Enhanced Error Messages**: Clearer guidance about host_dbus requirements - **Configuration Validation**: Better handling of Home Assistant add-on settings ### Changed - **BLE Recovery Logic**: More aggressive recovery for persistent connection failures - **Error Handling**: More specific error messages with actionable solutions - **Connection Flow**: Optimized fallback sequence between BLE and Classic Bluetooth ### Improved - **Reliability**: Significantly improved BLE connection success rate - **Automatic Recovery**: Comprehensive automatic recovery without manual intervention - **User Guidance**: Clearer error messages with specific configuration fixes - **Code Quality**: Fixed syntax errors and improved string formatting ## [0.1.37] - 2026-03-18 ### Fixed - **Classic Bluetooth**: Fixed `[Errno 12] Out of memory` errors by implementing automatic Bluetooth cache cleaning - **Connection Stability**: Improved Classic Bluetooth connection reliability with systematic channel testing (1, 2, 3) - **BLE Scanning**: Enhanced BLE scan error handling for missing RSSI attributes ### Added - **Automatic Cache Cleaning**: Bluetooth cache is now automatically cleared when memory errors occur - **Systematic Channel Testing**: Classic Bluetooth now tests channels 1, 2, 3 sequentially before falling back to BLE - **Enhanced Configuration**: Added `host_dbus`, `host_network`, and device permissions to config.yaml - **Improved Error Recovery**: Better handling of stale Bluetooth connections ### Changed - **Connection Logic**: Classic Bluetooth now continues trying other channels instead of immediately falling back to BLE - **Configuration**: Updated default settings for better Home Assistant compatibility - **Error Messages**: More specific guidance for connection issues ### Improved - **Reliability**: Classic Bluetooth connections are now more stable and recover from errors automatically - **Compatibility**: Better support for Home Assistant add-on environment - **User Experience**: Clearer error messages and automatic recovery ## [0.1.36] - 2026-03-19 ### Fixed - **BLE Scanning**: Fixed `'BLEDevice' object has no attribute 'rssi'` error by safely checking for RSSI attribute availability - **Web UI**: Improved BLE scan error handling to gracefully handle missing RSSI data ### Added - **Dark Theme**: Complete dark theme implementation with CSS variables and system preference support - **Responsive Design**: Mobile-first responsive layout with proper breakpoints (768px, 1024px, 1440px) - **Theme Toggle**: Interactive theme switcher with local storage persistence - **Touch Support**: Mobile-optimized button sizes and touch targets - **System Dark Mode**: Automatic dark/light mode detection via `@media (prefers-color-scheme: dark)` ### Changed - **Web UI**: Modernized entire UI with dark theme colors, improved spacing, and better typography - **Error Handling**: Enhanced BLE-specific error messages with troubleshooting guidance - **Pairing Function**: Clarified that pairing is only for Classic Bluetooth, not BLE - **HTML Structure**: Added responsive container system for better layout control ### Improved - **Accessibility**: Better ARIA labels, keyboard navigation, and color contrast - **Performance**: Optimized CSS with variables and reduced redundancy - **User Experience**: Clearer distinction between BLE and Classic Bluetooth workflows ## [0.1.35] - 2026-03-18 ## [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 - **Web UI**: Fixed "scanForDevices is not defined" error by injecting scan function into existing script section instead of separate script tag. - **Web UI**: Ensured scan JavaScript is properly scoped and available when button is clicked. ### Changed - **Web UI**: Improved JavaScript injection strategy to avoid scope issues. - **Web UI**: Scan function now injected directly into main script section for proper global availability. ## [0.1.32] - 2026-03-18 ### Fixed - **Web UI**: Fixed scan functionality not showing output by ensuring JavaScript is properly injected in all cases. - **Web UI**: Added default hint text to scan results area for better user guidance. - **Web UI**: Added comprehensive debug console logging to help diagnose scan issues. ### Changed - **Web UI**: Improved scan section injection logic to work with both `` and `` templates. - **Web UI**: Enhanced error handling and user feedback in scan functionality. ## [0.1.31] - 2026-03-18 ### Added - **Web UI**: Completely modernized and responsive design with improved mobile support, smooth animations, and professional styling. - **Web UI**: Enhanced debug scan section with loading indicators, signal strength visualization, and helpful troubleshooting tips. - **Web UI**: Added loading spinners, status indicators, and better error messages throughout the interface. ### Changed - **Web UI**: Updated CSS with modern design system including CSS variables, transitions, and responsive breakpoints. - **Web UI**: Improved button styling, card hover effects, and overall visual hierarchy. - **Web UI**: Better mobile responsiveness with optimized touch targets and single-column layouts on small screens. ### Fixed - **Web UI**: Fixed scan section visibility and positioning - now properly integrated into main content area. - **Web UI**: Improved scan button styling to match the modern design language. - **Web UI**: Added proper CSS styling for the scan section instead of inline styles. ## [0.1.30] - 2026-03-16 ### Fixed - **BLE Connection**: Restored fallback to raw address string when BLE scan fails to find the specific device. This fixes connectivity for devices that are reachable but not advertising (e.g. during rapid reconnection or BlueZ cache issues), resolving "BLE device not found during scan" errors. ### Added - **Web UI**: Restored support for the modern, responsive web interface. If the build artifacts are present in `fichero/web`, they will be served by default. - **Web UI**: Added a `?legacy=true` query parameter to the root URL to force the simple server-side rendered UI, which includes the new debug scan tool. ## [0.1.29] - 2026-03-16 ### Fixed - **BLE Connection**: Implemented a more robust recovery mechanism for `br-connection-not-supported` errors. The add-on will now automatically attempt to run `bluetoothctl remove` to clear the host's device cache before rescanning, which should improve connection reliability on affected systems. ## [0.1.28] - 2026-03-16 ### Fixed - **Pairing**: Added the `bluez` package to the Docker image, which provides the `bluetoothctl` command. This fixes the "not found" error when using the "Pair Device" and "Unpair Device" features. - **Changelog**: Consolidated the project's changelogs into a single, consistent file within the add-on, resolving inconsistencies from previous refactoring. ## [0.1.27] - 2026-03-16 ### Changed - **Project Structure**: Moved the `fichero` library into `fichero_printer/` to make the add-on self-contained. This simplifies the build process and removes the need for synchronization scripts. - Fixed invalid duplicate `version` keys in `pyproject.toml` and `config.yaml`. ## [0.1.26] - 2026-03-16 ### Fixed - **Build Process**: Fixed `too many links` Docker build error by removing the symlink-based approach. Introduced a `sync_addon.sh` script to automate copying the library into the add-on directory, which is required for the Home Assistant build system. ## [0.1.25] - 2026-03-08 ### Changed - **Build Process**: Replaced the manually copied `fichero` directory inside the Home Assistant add-on with a symbolic link. This eliminates code duplication and automates synchronization, simplifying the build process. ## [0.1.24] - 2026-03-08 ### Fixed - **Home Assistant Build**: Reverted the add-on's `Dockerfile` to a vendored code approach to resolve build failures caused by the Home Assistant build system's inability to access files outside the add-on directory. The add-on is now self-contained again. ## [0.1.23] - 2026-03-08 ### Changed - Updated the Home Assistant add-on's `Dockerfile` to install the main library as a package, completing the project structure refactoring. - Added `python-multipart` as an explicit dependency for the API server. ## [0.1.22] - 2026-03-08 ### Changed - **Refactored Project Structure**: Eliminated duplicated code by converting the project into an installable Python package. The Home Assistant add-on now installs the main library as a dependency instead of using a vendored copy, improving maintainability and preventing sync issues. ## [0.1.21] - 2026-03-08 ### Fixed - Synchronized the Home Assistant add-on's source code (`fichero_printer/fichero/`) with the main library to fix stale code and version mismatch issues. ## [0.1.20] - 2026-03-08 ### Changed - Refactored the embedded web UI in the API server to be loaded from a separate `index.html` file instead of a large inline string, improving maintainability. ## [0.1.19] - 2026-03-08 ### Added - Added `POST /unpair` endpoint and "Unpair Device" button in the web UI to remove a Bluetooth device from the host's paired devices. ## [0.1.18] - 2026-03-08 ### Added - Added `POST /pair` endpoint and "Pair Device" button in the web UI to easily pair/trust the printer via `bluetoothctl` for Classic Bluetooth connections. ## [0.1.17] - 2026-03-08 ### Added - Added automatic fallback to BLE connection if Classic Bluetooth (RFCOMM) fails with `[Errno 12] Out of memory`, a common issue on Linux with stale device states. ## [0.1.16] - 2026-03-08 ### Fixed - Corrected typos in the Code128B bit pattern table for characters '$' (ASCII 36) and ')' (ASCII 41), which caused incorrect barcodes to be generated. ## [0.1.15] - 2026-03-07 ### Fixed - Added BLE recovery path for `br-connection-not-supported`: the connector now forces a fresh LE scan target resolution and retries before returning an error. ## [0.1.14] - 2026-03-07 ### Fixed - Removed BLE fallback to raw MAC string when device resolution fails. The connector now requires a discovered LE device object, avoiding BlueZ BR/EDR misclassification that can cause `br-connection-not-supported`. ## [0.1.13] - 2026-03-07 ### Fixed - Treated BLE service-discovery disconnects (`failed to discover services, device disconnected`) as retryable transient errors in the BLE connect loop. ## [0.al.12] - 2026-03-07 ### Fixed - BLE target resolution now prefers discovered Bleak device objects (instead of raw address strings), improving BlueZ LE connection handling on hosts that previously returned `br-connection-not-supported`. ## [0.1.11] - 2026-03-07 ### Fixed - Handled `asyncio.TimeoutError` from BLE connect path so connection timeouts now return mapped API errors (502) instead of unhandled 500 exceptions. ## [0.1.10] - 2026-03-07 ### Changed - Added automatic BLE reconnect retry with linear backoff for transient timeout errors (including `br-connection-timeout`) before returning a failure. ## [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 - Root URL now serves a built-in printer web interface for Home Assistant with status, info, text printing, and image upload printing. ### Changed - Swagger docs remain available under `/docs` while the Home Assistant "Open" action now lands on the print UI. ## [0.1.7] - 2026-03-07 ### Fixed - Home Assistant ingress docs now use a custom Swagger UI route with a relative `openapi.json` URL, avoiding `404 /openapi.json` behind ingress prefixes. ### Changed - Home Assistant add-on now requests `full_access: true` in addition to Bluetooth capabilities to unblock Classic RFCOMM socket access on stricter hosts. ## [0.1.6] - 2026-03-07 ### Added - Added this `CHANGELOG.md` and established a release policy to update version and changelog for every change. ## [0.1.5] - 2026-03-07 ### Changed - Home Assistant add-on now requests `NET_RAW` in addition to `NET_ADMIN` for Classic Bluetooth RFCOMM sockets. - Add-on documentation updated with Classic permission requirements. ## [0.1.4] - 2026-03-07 ### Fixed - RFCOMM connection under `uvloop` now uses direct Bluetooth socket connect in a worker thread, avoiding address-family resolution issues. - Classic Bluetooth socket errors are mapped to API-safe printer errors instead of unhandled 500s. ## [0.1.3] - 2026-03-07 ### Changed - Home Assistant add-on metadata updated for ingress/web UI access. - API root endpoint now redirects to docs in an ingress-compatible way. - Added attribution for original upstream project and AI-assisted extension note.