diff --git a/README.md b/README.md index 8ce9049..4c4ccc7 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,10 @@ Or manually in HACS: 1. In HA, go to **Settings → Devices & Services → Add Integration** 2. Search for **"Siedle"** -3. You'll be redirected to a QR scanner page +3. You'll be redirected to a QR scanner page: + - **HTTPS setup** (e.g., Nabu Casa, Reverse Proxy): The QR scanner page is served directly by your Home Assistant instance. The phone camera can scan the QR code directly. + - **HTTP setup** (local network without HTTPS): Since the browser camera requires a secure context (HTTPS), you will be redirected to an external scanner page hosted at `stefan-altheimer.de`. The scanned data is sent back to your local HA instance via the callback URL. + - **Manual input**: If the camera doesn't work (e.g., desktop browser, no camera permission), the scanner page offers a manual input field. Simply scan the QR code with any QR scanner app on your phone, copy the text content and paste it into the field. 4. Scan the QR code from the Siedle app (with the second device or webcam) 5. The data will be automatically transmitted to HA diff --git a/README_DE.md b/README_DE.md index 7488fd4..03425aa 100644 --- a/README_DE.md +++ b/README_DE.md @@ -77,7 +77,10 @@ Oder manuell in HACS: 1. Gehe in HA zu **Einstellungen → Geräte & Dienste → Integration hinzufügen** 2. Suche nach **"Siedle"** -3. Du wirst zu einer QR-Scanner-Seite weitergeleitet +3. Du wirst zu einer QR-Scanner-Seite weitergeleitet: + - **HTTPS-Setup** (z.B. Nabu Casa, Reverse Proxy): Die QR-Scanner-Seite wird direkt von deiner Home Assistant-Instanz ausgeliefert. Die Handy-Kamera kann den QR-Code direkt scannen. + - **HTTP-Setup** (lokales Netzwerk ohne HTTPS): Da die Browser-Kamera einen sicheren Kontext (HTTPS) benötigt, wirst du auf eine extern gehostete Scanner-Seite unter `stefan-altheimer.de` weitergeleitet. Die gescannten Daten werden über die Callback-URL an deine lokale HA-Instanz zurückgesendet. + - **Manuelle Eingabe**: Falls die Kamera nicht funktioniert (z.B. Desktop-Browser, keine Kamera-Berechtigung), bietet die Scanner-Seite ein manuelles Eingabefeld. Scanne den QR-Code einfach mit einer beliebigen QR-Scanner-App auf deinem Handy, kopiere den Textinhalt und füge ihn in das Feld ein. 4. Scanne den QR-Code von der Siedle App (mit dem zweiten Gerät oder der Webcam) 5. Die Daten werden automatisch an HA übermittelt diff --git a/custom_components/siedle/__init__.py b/custom_components/siedle/__init__.py index cb65673..a303701 100644 --- a/custom_components/siedle/__init__.py +++ b/custom_components/siedle/__init__.py @@ -91,12 +91,20 @@ async def async_setup(hass: HomeAssistant, config: dict): """Set up the Siedle component.""" hass.data.setdefault(DOMAIN, {}) - # Register QR callback API endpoint only once - if not any(isinstance(view, SiedleQRCallbackView) for view in hass.http.app.router._resources): + # Register QR callback and scanner API endpoints only once + registered_names = {getattr(r, 'name', None) for r in hass.http.app.router._resources} + + if "api:siedle:qr_callback" not in registered_names: _LOGGER.info("Registering Siedle QR callback view at /api/siedle/qr_callback") hass.http.register_view(SiedleQRCallbackView()) else: - _LOGGER.info("Siedle QR callback view already registered") + _LOGGER.debug("Siedle QR callback view already registered") + + if "api:siedle:qr_scanner" not in registered_names: + _LOGGER.info("Registering Siedle QR scanner view at /api/siedle/qr_scanner") + hass.http.register_view(SiedleQRScannerView()) + else: + _LOGGER.debug("Siedle QR scanner view already registered") return True @@ -709,6 +717,339 @@ async def _async_update_data(self): raise UpdateFailed(f"Error communicating with API: {err}") +QR_SCANNER_HTML = """ + +
+ + +Scannen Sie Ihren Siedle QR-Code
+