Repository navigation
Implement RFC-0019's allowlisted Home Assistant action capability - #19
Merged
Merged
Conversation
home_assistant.set_entity_state (mutating/external/required) turns an allowlisted light or switch entity on or off. Reads current state first so a proposal matching it is a real, narrated no-op that never contacts Home Assistant's service-call endpoint; a real change is verified against the service call's own response before reporting success, never trusting a 200 status alone. Domain scope (light/switch only) is enforced at three independent points, per RFC-0019's own review finding that a single point isn't enough (Home Assistant's climate domain has real turn_on/turn_off services, so a bypassed check wouldn't fail safely by accident): write_config() rejects a bad domain at the source, a new _control_policy_check re-derives and re-confirms it at the executor's policy stage, and the implementation itself checks a third time immediately before constructing the service-call URL. Adds a second, independent allowlist and policy toggle (controllable_entities/home_assistant_control_enabled), distinct from RFC-0018's read allowlist/toggle, with controllable_entities enforced as a strict subset of allowlisted_entities at write time. Extends the existing POST /api/v1/conversation/home-assistant endpoint (now requiring the two new fields in every write, matching the existing full-replace fields) and fixes Console's existing save-connection flow to round-trip them, since the endpoint's contract changed under it. Console UI for editing control settings itself is not built here, per RFC-0019's own Non-Goals. Reuses RFC-0017's confirmation wire format completely unchanged for this project's first mutating capability -- no new fields, no new halting behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
kasunben
marked this pull request as ready for review
August 21, 2026 22:50
kasunben
added a commit
that referenced
this pull request
Aug 21, 2026
PR #19 shipped home_assistant.set_entity_state, the extended home-assistant.json config surface, and the Console compatibility fix for the endpoint's new required fields. Console's own settings UI for the control toggle/picker remains the one real gap, alongside the already-disclosed real-hardware qualification blocker. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the one mutating capability RFC-0019 (Accepted) maps:
home_assistant.set_entity_state— this project's first capability with a real, physical effect, not just an information disclosure.sovereign_homeassistant.py) — reads current state before acting, so a proposal matching current state is a real, narrated no-op (changed: false) that never contacts Home Assistant's service-call endpoint. A real change is verified against the service call's own response (the changed-states list) before reporting success — never trusting a 200 status alone.write_config()rejects a non-light/switch domain at the source, a new_control_policy_checkre-derives and re-confirms domain at the executor's stage-3 policy check, and the implementation itself checks a third time immediately before constructing the service-call URL. All three are independently tested, including an adversarial test that bypasseswrite_config()entirely (writing the config file directly) to prove the other two checks actually catch it — grounded in a real finding: Home Assistant'sclimatedomain has realclimate.turn_on/climate.turn_offservices, so a bypassed check wouldn't fail safely by accident the way an invalid service name might.controllable_entities/home_assistant_control_enabled), distinct from RFC-0018's own read allowlist/toggle — enabling reading never silently enables control.controllable_entitiesis enforced as a strict subset ofallowlisted_entitiesat write time.POST /api/v1/conversation/home-assistantendpoint rather than adding a new one — the two new fields are now required in every write, matching the existing full-replace semantics ofenabled/base_url/allowlisted_entities.A real regression this PR had to fix along the way
Extending the POST endpoint's required fields would have broken Console's already-shipped "Save connection" button — it currently sends only the three RFC-0018-era fields. Fixed by having
console.jsload, retain, and resendcontrol_enabled/controllable_entitiesunchanged on every save, even though this PR builds no UI to edit them yet (that's Console's own follow-up, per RFC-0019's Non-Goals). Without this fix, every existing "Save connection" click would now 400.Not included (explicit RFC-0019 follow-up, not this PR)
Console's settings UI for the control toggle and the controllable-entities picker. Real-hardware qualification also depends on the same unresolved external dependency RFC-0018 already disclosed — no Home Assistant instance exists on the household network yet.
Test plan
test_homeassistant_capabilities.py(config storage + domain validation,_control_policy_check, the implementation's no-op/success/not-confirmed paths, the adversarial domain-bypass test, full executor confirmation round trip),test_conversation.py(registry count,build_policymerging),test_conversation_service.py(extended/home-assistantendpoint validation including the newINVALID_CONTROL_CONFIGURATIONrejection path, mutating-capability confirmation flow at the HTTP layer, cross-toggle independence).🤖 Generated with Claude Code