Skip to content

refactor: update QR scanner instructions and improve config flow for …#9

Merged
Kannix2005 merged 1 commit into
mainfrom
local_qr
Mar 5, 2026
Merged

refactor: update QR scanner instructions and improve config flow for …#9
Kannix2005 merged 1 commit into
mainfrom
local_qr

Conversation

@Kannix2005
Copy link
Copy Markdown
Owner

…local handling

Copilot AI review requested due to automatic review settings March 5, 2026 14:07
@Kannix2005 Kannix2005 merged commit deef7b9 into main Mar 5, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_scanner on 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"
Copy link

Copilot AI Mar 5, 2026

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.
# 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"
Copy link

Copilot AI Mar 5, 2026

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants