feat(tools): home_assistant tool for HA REST API#6464
Open
theonlyhennygod wants to merge 1 commit intomasterfrom
Open
feat(tools): home_assistant tool for HA REST API#6464theonlyhennygod wants to merge 1 commit intomasterfrom
theonlyhennygod wants to merge 1 commit intomasterfrom
Conversation
Adds a `home_assistant` Tool that talks to a self-hosted Home Assistant instance via its REST API. Read actions (`get_state`, `list_states`, `list_services`) require `ToolOperation::Read`; the mutating `call_service` action requires `ToolOperation::Act` and is further restricted by an operator-controlled `allowed_domains` allowlist. `HomeAssistantConfig` is disabled by default. The access token is marked `#[secret]` (encrypted at rest when `[secrets] encrypt = true`) and falls back to the `HOME_ASSISTANT_TOKEN` env var. The registry status flips Available -> Active when `home_assistant.enabled` is set. Adds a setup-guide doc, a `zeroclaw integrations info "Home Assistant"` hint arm, and a CHANGELOG-next entry. Closes #6448
0084e27 to
2e9d172
Compare
Collaborator
Author
|
Rebased onto current master (was conflicting against #6386 which moved the integrations registry to a schema-driven, single-loop catalog). What changed in the diff vs. the original push:
Note: under the new registry, Re-validated locally: |
This was referenced May 6, 2026
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
masterhome_assistantTool that drives a self-hosted Home Assistant instance via its REST API. Until now,crates/zeroclaw-runtime/src/integrations/registry.rs:634-639declared HA asComingSoonwith no implementation behind it.get_state,list_states,list_services) gate onToolOperation::Read;call_servicegates onToolOperation::ActAND a configurableallowed_domainsallowlist so operators control the blast radius.status_fnto flipAvailable → Activewhenhome_assistant.enabled = true, and the developer page picks it up automatically.base_url.zeroclaw-config(additive[home_assistant]block, default disabled),zeroclaw-tools(new module),zeroclaw-runtime/src/tools/mod.rs(config-gated registration inall_tools_with_runtime),zeroclaw-runtime/src/integrations/{mod,registry}.rs(status flip + setup-hint arm), docs.Closes #6448. Sibling tracking issues: [Feature]: Philips Hue integration tool #6449 (Hue), [Feature]: 8Sleep integration tool #6450 (8Sleep).Validation Evidence (required)
cargo fmt --all -- --check cargo clippy -p zeroclaw-config -p zeroclaw-tools -p zeroclaw-runtime --all-targets -- -D warnings cargo test -p zeroclaw-config -p zeroclaw-tools -p zeroclaw-runtime cargo check -p zeroclaw-gatewaycargo fmt --all -- --check→ clean (no diff aftercargo fmt --allwas run).cargo clippy ...→Finisheddevprofile [unoptimized + debuginfo] target(s) in 47.60s. No warnings.cargo test -p zeroclaw-config -p zeroclaw-tools -p zeroclaw-runtime→test result: ok. 620 passed; 0 failed; 0 ignored(zeroclaw-config)test result: ok. 1641 passed; 0 failed; 1 ignored(zeroclaw-tools)test result: ok. 1158 passed; 0 failed; 0 ignored(zeroclaw-runtime)home_assistant::tests::*— name, schema shape (action enum, required fields), URL/base normalization, allowlist trimming, missing-action / unknown-action / missing-entity / missing-domain / missing-service / disallowed-domain / empty-allowlist paths,spec()reflection.home_assistant_available_when_not_configuredandhome_assistant_active_when_enabled— confirm the developer-page card flips when config is set.cargo check -p zeroclaw-gateway→ builds; gateway surfaces tools viastate.tools_registryfromall_tools_with_runtime, so the new tool auto-appears atGET /api/toolswhen[home_assistant] enabled = true.🔜 Coming Soonto⚪ Available(and✅ Activeonce configured) — the registry test exercises both states.zeroclaw integrations info "Home Assistant"now prints the LLAT setup steps (the new arm inshow_integration_info).call_serviceagainst an actuallight.turn_onis left to follow-up smoke once the PR lands. The unit tests cover error paths (missing fields, disallowed domains) but not the HTTP success path../dev/ci.sh allbecause the change is scoped to three crates + docs + a changelog entry; the targeted clippy+test runs already gated those crates with-D warnings.Security & Privacy Impact (required)
home_assistant.base_url. Disabled by default; the operator opts in.access_tokenfield onHomeAssistantConfigcarries#[secret], so it's encrypted at rest when[secrets] encrypt = true. Token also resolves fromHOME_ASSISTANT_TOKENenv var as a fallback.http://homeassistant.local:8123,test-token,light.kitchen).allowed_domainscould let the agent trigger unexpected automations. Mitigation:allowed_domainsis enforced server-side in the tool'sexecute(not just in the schema); empty allowlist blocks allcall_servicecalls; defaults are conservative (nolock, nocover, nonotify).Compatibility (required)
enabled: false.Config::default()includeshome_assistant: HomeAssistantConfig::default(), so existing configs missing[home_assistant]continue to deserialize unchanged.[home_assistant]block; newHOME_ASSISTANT_TOKENenv var fallback. No CLI changes.[home_assistant] enabled = true,base_url, and eitheraccess_tokenorHOME_ASSISTANT_TOKEN.Rollback (required for
risk: mediumandrisk: high)[home_assistant] enabled = falsein~/.zeroclaw/config.toml(or remove the block) and restart the agent. The tool is unregistered on next boot.home_assistant.enabled(boolean) is the master switch.home_assistant.allowed_domainsis the per-action throttle.home_assistant: enabled but no access token found ...or... base_url is empty — skipping registrationindicate config issues.Home Assistant {action} failed (4xx/5xx)indicates upstream HA problems (token revoked, instance unreachable).home_assistantif either token or base_url is missing.