Skip to content

Fix config screens ignoring per-instance client certificate and URL#17

Merged
db1996 merged 1 commit into
db1996:mainfrom
hectorsouthern:fix/config-screen-instance-client
Jul 21, 2026
Merged

Fix config screens ignoring per-instance client certificate and URL#17
db1996 merged 1 commit into
db1996:mainfrom
hectorsouthern:fix/config-screen-instance-client

Conversation

@hectorsouthern

Copy link
Copy Markdown
Contributor

Fixes #16

The config screens' initial HomeAssistantClient was built from legacy global settings (remote URL, no per-instance cert), so behind mTLS every registry/entity fetch got a 403 and the entity picker never loaded; actions could then save with an empty entity_id and fail at runtime with HTTP 400.

  • ClientViewModelFactory now builds the initial client from the active instance (resolveUrl() + per-instance cert), falling back to legacy settings.
  • BaseViewModel.client is assignable; changeInstance() (CallService/GetState/OnTriggerState) keeps the per-instance client for subsequent operations.

Built the APK and tested on-device against HA behind Cloudflare mTLS: entity list loads and the saved action runs successfully. Developed with AI assistance (Claude); reviewed and validated end-to-end by me.

🤖 Generated with Claude Code

The plugin config screens built their initial HomeAssistantClient in
ClientViewModelFactory from the legacy global settings (remote URL only,
legacy client-cert prefs which are cleared after migration to the
instance repository). For servers behind mTLS (e.g. Cloudflare client
certificates) every request from that client is rejected (HTTP 403), so
the registry/entity fetch triggered by pickService() always failed and
the entity picker never loaded.

Selecting an instance already built a correct per-instance client in
changeInstance(), but it was discarded after loading services/entities,
so subsequent launchClientOperation calls still used the broken client.

Changes:
- ClientViewModelFactory now builds the initial client from the active
  instance (resolveUrl + per-instance cert), falling back to legacy
  settings when no instance exists.
- BaseViewModel.client is now assignable; changeInstance() in the
  CallService, GetState and OnTriggerState view models stores the
  per-instance client so all later operations use it.

Tested on-device against a Home Assistant instance behind a Cloudflare
tunnel with mandatory mTLS: entity lists now load and actions save with
a populated entity_id.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@db1996
db1996 merged commit 8c580f1 into db1996:main Jul 21, 2026
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.

Entity list never loads (HTTP 403) when HA is behind mTLS — config screens don't use the per-instance client certificate

2 participants