refactor: update QR scanner instructions and improve config flow for …#9
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the QR-scanner config flow to always use the QR scanner page served by the Home Assistant instance itself, and updates documentation accordingly while removing the legacy external-scanner constant.
Changes:
- Simplify config flow QR-scanner URL generation to always point at
/api/siedle/qr_scanneron the selected HA base URL. - Remove the external QR-scanner URL constant and references.
- Update EN/DE READMEs to describe the new QR-scanner behavior and HTTPS/camera constraints.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
custom_components/siedle/config_flow.py |
Removes external-scanner fallback logic and builds a single local QR-scanner URL. |
custom_components/siedle/const.py |
Removes the external QR-scanner URL constant. |
custom_components/siedle/fcm_handler.py |
Removes a comment line above the Firebase configuration constant. |
README.md |
Updates QR-scanning instructions to match the new local-scanner flow. |
README_DE.md |
Updates German QR-scanning instructions to match the new local-scanner flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 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" |
There was a problem hiding this comment.
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).
| 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" |
| # 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" |
There was a problem hiding this comment.
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.
| 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("/") |
…local handling