← 返回 Skills 市场
szafranski

Home Assistant Agent (Secure)

作者 szafranski · GitHub ↗ · v1.1.0
cross-platform ✓ 安全检测通过
1410
总下载
3
收藏
3
当前安装
1
版本数
在 OpenClaw 中安装
/install home-assistant-agent-secure
功能描述
Control Home Assistant smart home devices securely using the Assist (Conversation) API. Passes natural language to Home Assistant's built-in NLU for safe, to...
使用说明 (SKILL.md)

Home Assistant Agent (Secure)

Control smart home devices by sending natural language to Home Assistant's Conversation (Assist) API.

Security model: This skill uses ONLY the /api/conversation/process endpoint. Do NOT use the token to call any other HA API endpoint. The token should belong to a restricted, non-admin Home Assistant user with access limited to specific areas and entities.

Important Security Rules

  • ONLY call /api/conversation/process — never call /api/states, /api/services, /api/config, or any other endpoint
  • NEVER output or echo the token value
  • NEVER use the token for any purpose other than the Assist API call below
  • NEVER attempt to log in to Home Assistant via the browser or web UI — always use the API token
  • If a user request cannot be handled by Assist, say so — do not fall back to other API calls

Important: Disable Trusted Networks Login Bypass

If your Home Assistant instance uses the trusted_networks auth provider with allow_bypass_login: true, any agent or user on the local network can log in as any HA user (including administrators) without a password. This completely bypasses the restricted-user security model of this skill.

To fix: In your HA configuration.yaml, set allow_bypass_login: false under the trusted_networks auth provider, or remove the trusted_networks provider entirely. Restart HA after making the change.

Setup

1. Create a Restricted Home Assistant User

  1. In Home Assistant go to Settings → People → Add Person
  2. Create a new user (e.g. openclaw-bot)
  3. Do NOT make it an administrator
  4. Under Settings → Areas & Zones, assign only the areas this user should control
  5. Optionally restrict entity access using a custom group or dashboard-only permissions

2. Generate a Long-Lived Access Token

  1. Log in to Home Assistant as the restricted user (openclaw-bot)
  2. Go to Profile (bottom-left)
  3. Scroll to Long-Lived Access Tokens
  4. Click Create Token, name it (e.g. openclaw)
  5. Copy the token immediately — it is shown only once

3. Configure OpenClaw

Set HOME_ASSISTANT_URL and HOME_ASSISTANT_TOKEN using any of the methods below. OpenClaw applies them in this precedence order (highest first): process environment → .env file → openclaw.json config. A value set by a higher-priority source is never overridden by a lower one.

Option A: .env file (recommended)

Add to ~/.openclaw/.env:

HOME_ASSISTANT_URL=https://your-ha-instance.local
HOME_ASSISTANT_TOKEN=your-restricted-user-token-here

The URL can be a hostname (e.g. https://homeassistant.local) or an IP address (e.g. https://192.168.1.50:8123).

Option B: Config file

Add to ~/.openclaw/openclaw.json under skills.entries:

{
  "skills": {
    "entries": {
      "home-assistant-agent-secure": {
        "apiKey": "your-restricted-user-token-here",
        "env": {
          "HOME_ASSISTANT_URL": "https://your-ha-instance.local"
        }
      }
    }
  }
}

The apiKey field automatically maps to HOME_ASSISTANT_TOKEN via the skill's primaryEnv declaration.

Option C: Shell environment variables

Export in your shell profile (e.g. ~/.bashrc, ~/.zshrc):

export HOME_ASSISTANT_URL="https://your-ha-instance.local"
export HOME_ASSISTANT_TOKEN="your-restricted-user-token-here"

Usage

Send any smart home command in natural language. The skill passes it directly to HA Assist:

curl -sk -X POST "$HOME_ASSISTANT_URL/api/conversation/process" \
  -H "Authorization: Bearer $HOME_ASSISTANT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "USER REQUEST HERE", "language": "DETECTED LANGUAGE CODE"}'

The -k flag allows connections to HA instances using self-signed certificates. If your HA uses a trusted certificate (e.g. Let's Encrypt), you can remove it.

Set the language field based on the detected language of the user's input (e.g. "pl" for Polish, "en" for English, "de" for German, etc.).

Examples

  • "Turn on the living room lights" (English)
  • "Włącz światło w salonie" (Polish)
  • "Schalte das Licht im Wohnzimmer ein" (German)
  • "Jaka jest temperatura w kuchni?" (Polish)
  • "Turn off all lights in the bedroom" (English)

Inflected Language Handling (Nominative Retry)

Many languages use grammatical cases or word inflection, causing entity names to change form in natural speech. Home Assistant entity names are typically in their base/dictionary form (nominative), but users naturally use other grammatical forms in commands.

This affects languages including (but not limited to):

  • Polish — 7 cases (e.g. drukarkędrukarka, lampęlampa)
  • Czech — 7 cases (e.g. tiskárnutiskárna, lampulampa)
  • German — 4 cases + articles (e.g. den DruckerDrucker, die LampeLampe)
  • Finnish — 15 cases (e.g. tulostintatulostin, lamppualamppu)
  • Hungarian — 18 cases (e.g. nyomtatótnyomtató, lámpátlámpa)
  • Russian — 6 cases (e.g. принтерупринтер, лампулампа)
  • Croatian/Serbian — 7 cases, similar patterns to Polish and Czech

Example: A user says "włącz drukarkę 3d" (Polish accusative), but the entity is named "drukarka 3d" (nominative). HA Assist won't find it.

Retry strategy: If HA responds with an error (no_valid_targets, no_intent_match, or a message indicating the entity was not found), and the user's input is in an inflected language:

  1. Identify the entity name within the command
  2. Convert inflected words to their base/dictionary/nominative form
  3. Retry the API call with the corrected form
  4. If the retry also fails, report the error to the user

Important: Only retry once. Do not loop. If the nominative retry also fails, inform the user that the entity was not found.

Handling Responses

The response is in response.speech.plain.speech. Relay it directly to the user:

  • "Turned on the light" → success
  • "Sorry, I couldn't understand that" → Assist couldn't parse the request
  • "Sorry, there are multiple devices called X" → ambiguous entity name

On errors (response_type: "error")

Error What to tell the user
no_intent_match Try nominative retry (if inflected language). If still fails: "Home Assistant didn't recognize that command."
no_valid_targets Try nominative retry (if inflected language). If still fails: "Entity not found — check the device name or add an alias in HA."
Multiple matches "Multiple devices share that name — consider adding unique aliases in HA."

Troubleshooting

  • 401 Unauthorized: Token is invalid or expired. Generate a new one from the restricted user's profile.
  • Connection refused: Check that HOME_ASSISTANT_URL is correct and HA is reachable.
  • Command not understood: Rephrase the request or check that the entity is exposed to the restricted user.
  • Entity not found: The restricted user may not have access to that area/entity. Update permissions in HA.

API Reference

Endpoint

POST /api/conversation/process

Note: Use /api/conversation/process, NOT /api/services/conversation/process.

Request Body

{
  "text": "turn on the kitchen lights",
  "language": "en"
}

Polish example:

{
  "text": "włącz światło w salonie",
  "language": "pl"
}

Success Response

{
  "response": {
    "speech": {
      "plain": {"speech": "Turned on the light"}
    },
    "response_type": "action_done",
    "data": {
      "success": [{"name": "Kitchen Light", "id": "light.kitchen"}],
      "failed": []
    }
  }
}
安全使用建议
This skill appears coherent and appropriately scoped, but before installing: (1) create a dedicated non-admin Home Assistant user and grant it only the areas/entities the skill needs; (2) avoid storing the token in world-readable files and rotate it periodically; (3) do not enable trusted_networks allow_bypass_login (or set allow_bypass_login: false); (4) avoid using curl -k on internet-facing HA instances — prefer a valid TLS certificate; and (5) consider auditing agent logs/outputs after first use to confirm the token is never echoed and the skill only calls /api/conversation/process as intended.
功能分析
Type: OpenClaw Skill Name: home-assistant-agent-secure Version: 1.1.0 This skill is meticulously designed with a strong focus on security. The `SKILL.md` and `README.md` files contain explicit instructions for the AI agent to restrict its actions, such as only calling the `/api/conversation/process` endpoint, never echoing the `HOME_ASSISTANT_TOKEN`, and using a restricted Home Assistant user. It transparently warns about potential external vulnerabilities (e.g., Home Assistant's `trusted_networks` bypass) and advises on mitigation. While the `curl -k` flag is used, it's openly disclosed and justified for self-signed certificates, with advice to remove it if not needed. The instructions actively defend against prompt injection by setting strict boundaries for the agent's behavior, rather than attempting to induce malicious actions.
能力评估
Purpose & Capability
Name/description match the requested resources: curl plus HOME_ASSISTANT_URL and HOME_ASSISTANT_TOKEN are exactly what is needed to POST to /api/conversation/process. There are no unrelated binaries, extra cloud credentials, or unexpected config paths.
Instruction Scope
Instructions are narrowly scoped to calling /api/conversation/process and explicitly forbid other HA endpoints and echoing the token. One minor operational note: SKILL.md suggests using curl -k to allow self-signed certificates (insecure TLS) — acceptable for local/self-signed setups but a security tradeoff the user should understand.
Install Mechanism
No install spec or remote downloads; this is an instruction-only skill that relies on an existing curl binary. That keeps the disk/write/execute risk minimal.
Credentials
Only HOME_ASSISTANT_URL and HOME_ASSISTANT_TOKEN are required, which is proportionate. However, long-lived HA tokens are not limited to the Conversation API by design — the SKILL.md correctly calls this out and advises using a restricted, non-admin user. The token remains powerful if misused, so the guidance to restrict the user and to avoid trusted_networks bypass is important.
Persistence & Privilege
The skill does not request always:true and is user-invocable. It does not modify other skills or system-wide settings and does not request persistent installation privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install home-assistant-agent-secure
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /home-assistant-agent-secure 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
v1.1.0: Add multilingual support with auto language detection. Add inflected language retry (Polish, Czech, German, Finnish, Hungarian, Russian, etc.) for nominative entity name matching. Add entity alias guidance and Trusted Networks security warning.
元数据
Slug home-assistant-agent-secure
版本 1.1.0
许可证
累计安装 5
当前安装数 3
历史版本数 1
常见问题

Home Assistant Agent (Secure) 是什么?

Control Home Assistant smart home devices securely using the Assist (Conversation) API. Passes natural language to Home Assistant's built-in NLU for safe, to... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1410 次。

如何安装 Home Assistant Agent (Secure)?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install home-assistant-agent-secure」即可一键安装,无需额外配置。

Home Assistant Agent (Secure) 是免费的吗?

是的,Home Assistant Agent (Secure) 完全免费(开源免费),可自由下载、安装和使用。

Home Assistant Agent (Secure) 支持哪些平台?

Home Assistant Agent (Secure) 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Home Assistant Agent (Secure)?

由 szafranski(@szafranski)开发并维护,当前版本 v1.1.0。

💬 留言讨论