AgentSkillsCN

homeassistant

通过 Home Assistant REST API 控制 Home Assistant(灯光、开关、温控、场景、脚本)。当 Nicolai 请求控制家中的设备、查询实体状态,或运行 Home Assistant 服务时,可使用此技能。

SKILL.md
--- frontmatter
name: homeassistant
description: Control Home Assistant (lights, switches, climate, scenes, scripts) via the Home Assistant REST API. Use when Nicolai asks to control devices at home, query entity states, or run Home Assistant services.

Home Assistant (REST) — Quick Use

Security first

  • Prefer a dedicated Home Assistant user for this assistant.
  • Use a Long-Lived Access Token (LLAT) from that user.
  • Never commit tokens to git; store them in secrets/ (gitignored).
  • If HA is exposed on the public internet, ensure HTTPS, strong auth, and ideally IP restrictions / VPN.

Setup (one-time)

  1. Set your HA base URL (you have: https://ghar.nicolaischmid.de).
  2. Save token to a local secret file:
    • mkdir -p /root/.openclaw/workspace/secrets
    • chmod 700 /root/.openclaw/workspace/secrets
    • write token to: /root/.openclaw/workspace/secrets/ha_token
    • chmod 600 /root/.openclaw/workspace/secrets/ha_token

Optional env overrides:

  • HA_URL (default taken from secrets/ha_url if present)
  • HA_TOKEN (default read from secrets/ha_token)

Inventory / context

  • The current device/entity overview lives in:
    • skills/homeassistant/references/inventory-nice.md (most useful controls)
    • skills/homeassistant/references/inventory.md (broader controllable list)
  • Refresh anytime by running:
    • node scripts/ha-refresh-context.mjs

Commands

Wrapper script (JSON by default):

  • Ping:

    • node scripts/ha.mjs ping
  • Get entity state:

    • node scripts/ha.mjs state light.living_room
  • Call a service:

    • node scripts/ha.mjs call light turn_on '{"entity_id":"light.living_room","brightness_pct":50}'
  • List entities (compact):

    • node scripts/ha.mjs list --domain light

REST endpoints (reference)

  • GET /api/
  • GET /api/states/<entity_id>
  • POST /api/services/<domain>/<service> with JSON body

Docs: