Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ 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:
- **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.
3. You'll be redirected to a QR scanner page served directly by your Home Assistant instance:
- **With camera** (HTTPS required): If your HA is accessible via HTTPS (e.g., Nabu Casa, Reverse Proxy), the phone camera can scan the QR code directly in the browser.
- **Manual input**: If the camera doesn't work (e.g., HTTP-only setup, 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

Expand Down
7 changes: 3 additions & 4 deletions README_DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ 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:
- **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.
3. Du wirst zu einer QR-Scanner-Seite weitergeleitet, die direkt von deiner Home Assistant-Instanz bereitgestellt wird:
- **Mit Kamera** (HTTPS erforderlich): Wenn dein HA über HTTPS erreichbar ist (z.B. Nabu Casa, Reverse Proxy), kann die Handy-Kamera den QR-Code direkt im Browser scannen.
- **Manuelle Eingabe**: Falls die Kamera nicht funktioniert (z.B. HTTP-Only-Setup, 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

Expand Down
19 changes: 3 additions & 16 deletions custom_components/siedle/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import logging
import voluptuous as vol
import json
from urllib.parse import quote

from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.helpers import selector

from .const import (
DOMAIN,
CONF_QR_CODE_URL,
CONF_EXT_SIP_ENABLED,
CONF_EXT_SIP_HOST,
CONF_EXT_SIP_PORT,
Expand Down Expand Up @@ -96,25 +94,14 @@ async def async_step_user(self, user_input=None):
except Exception as e:
_LOGGER.error("Error registering view: %s", e)

# Build callback URL for QR scanner
# Camera requires HTTPS (secure context). Prefer local HTTPS,
# fall back to external hosted scanner if only HTTP is available.
# Build URL for QR scanner page (served by HA itself)
external = self.hass.config.external_url
internal = self.hass.config.internal_url
base_url = external or internal or "http://homeassistant.local:8123"

Copilot AI Mar 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base_url = external or internal can select an HTTP external_url even when an HTTPS internal_url is available, which will prevent in-browser camera scanning despite HTTPS being configured. Consider preferring an HTTPS URL when either external_url or internal_url starts with https:// (and fall back otherwise).

Suggested change
base_url = external or internal or "http://homeassistant.local:8123"
# Prefer an HTTPS URL (internal or external) when available, fall back otherwise
https_candidates = [url for url in (internal, external) if url and url.startswith("https://")]
if https_candidates:
base_url = https_candidates[0]
else:
base_url = external or internal or "http://homeassistant.local:8123"

Copilot uses AI. Check for mistakes.

Copilot AI Mar 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base_url may be configured with a trailing slash (user-provided internal/external URL). Concatenating with "/api/..." can produce a //api/... URL; strip the trailing slash (e.g., base_url.rstrip('/')) before building qr_scanner_url.

Suggested change
base_url = external or internal or "http://homeassistant.local:8123"
base_url = external or internal or "http://homeassistant.local:8123"
base_url = base_url.rstrip("/")

Copilot uses AI. Check for mistakes.

flow_id = self.flow_id
callback_url = quote(f"{base_url}/api/siedle/qr_callback", safe='')

# Check if we have HTTPS available -> use local scanner
if (external and external.startswith("https://")) or \
(internal and internal.startswith("https://")):
# Use HTTPS URL for local scanner page
https_base = external if (external and external.startswith("https://")) else internal
qr_scanner_url = f"{https_base}/api/siedle/qr_scanner?config_flow_id={flow_id}&callback_url={callback_url}"
else:
# No HTTPS - fall back to external hosted scanner page
qr_scanner_url = f"{CONF_QR_CODE_URL}?config_flow_id={flow_id}&callback_url={callback_url}"
qr_scanner_url = f"{base_url}/api/siedle/qr_scanner?config_flow_id={flow_id}"

return self.async_external_step(
step_id="qr_scan",
url=qr_scanner_url,
Expand Down
3 changes: 0 additions & 3 deletions custom_components/siedle/const.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Constants for Siedle integration."""
DOMAIN = "siedle"

# Config Flow
CONF_QR_CODE_URL = "http://www.stefan-altheimer.de/siedle/index.html"

# Defaults
DEFAULT_NAME = "Siedle"
DEFAULT_SCAN_INTERVAL = 300
Expand Down
1 change: 0 additions & 1 deletion custom_components/siedle/fcm_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

_LOGGER = logging.getLogger(__name__)

# Siedle Firebase Configuration (extracted from APK)
SIEDLE_FIREBASE = {
"project_id": "siedle-sus-android",
"api_key": "AIzaSyDBeZC0fOq0b3WHZBUzvU2FM5nrLgglFQw",
Expand Down