{"skill":{"slug":"home-assistant","displayName":"Home Assistant","summary":"Control Home Assistant smart home devices, run automations, and receive webhook events. Use when controlling lights, switches, climate, scenes, scripts, or any HA entity. Supports bidirectional communication via REST API (outbound) and webhooks (inbound triggers from HA automations).","description":"---\nname: home-assistant\ndescription: Control Home Assistant smart home devices, run automations, and receive webhook events. Use when controlling lights, switches, climate, scenes, scripts, or any HA entity. Supports bidirectional communication via REST API (outbound) and webhooks (inbound triggers from HA automations).\nmetadata: {\"clawdbot\":{\"emoji\":\"🏠\",\"requires\":{\"bins\":[\"jq\",\"curl\"]}}}\n---\n\n# Home Assistant\n\nControl your smart home via Home Assistant's REST API and webhooks.\n\n## Setup\n\n### Option 1: Config File (Recommended)\n\nCreate `~/.config/home-assistant/config.json`:\n```json\n{\n  \"url\": \"https://your-ha-instance.duckdns.org\",\n  \"token\": \"your-long-lived-access-token\"\n}\n```\n\n### Option 2: Environment Variables\n\n```bash\nexport HA_URL=\"http://homeassistant.local:8123\"\nexport HA_TOKEN=\"your-long-lived-access-token\"\n```\n\n### Getting a Long-Lived Access Token\n\n1. Open Home Assistant → Profile (bottom left)\n2. Scroll to \"Long-Lived Access Tokens\"\n3. Click \"Create Token\", name it (e.g., \"Clawdbot\")\n4. Copy the token immediately (shown only once)\n\n## Quick Reference\n\n### List Entities\n\n```bash\ncurl -s -H \"Authorization: Bearer $HA_TOKEN\" \"$HA_URL/api/states\" | jq '.[].entity_id'\n```\n\n### Get Entity State\n\n```bash\ncurl -s -H \"Authorization: Bearer $HA_TOKEN\" \"$HA_URL/api/states/light.living_room\"\n```\n\n### Control Devices\n\n```bash\n# Turn on\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" -H \"Content-Type: application/json\" \\\n  \"$HA_URL/api/services/light/turn_on\" -d '{\"entity_id\": \"light.living_room\"}'\n\n# Turn off\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" -H \"Content-Type: application/json\" \\\n  \"$HA_URL/api/services/light/turn_off\" -d '{\"entity_id\": \"light.living_room\"}'\n\n# Set brightness (0-255)\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" -H \"Content-Type: application/json\" \\\n  \"$HA_URL/api/services/light/turn_on\" -d '{\"entity_id\": \"light.living_room\", \"brightness\": 128}'\n```\n\n### Run Scripts & Automations\n\n```bash\n# Trigger script\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" \"$HA_URL/api/services/script/turn_on\" \\\n  -H \"Content-Type: application/json\" -d '{\"entity_id\": \"script.goodnight\"}'\n\n# Trigger automation\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" \"$HA_URL/api/services/automation/trigger\" \\\n  -H \"Content-Type: application/json\" -d '{\"entity_id\": \"automation.motion_lights\"}'\n```\n\n### Activate Scenes\n\n```bash\ncurl -X POST -H \"Authorization: Bearer $HA_TOKEN\" \"$HA_URL/api/services/scene/turn_on\" \\\n  -H \"Content-Type: application/json\" -d '{\"entity_id\": \"scene.movie_night\"}'\n```\n\n## Common Services\n\n| Domain | Service | Example entity_id |\n|--------|---------|-------------------|\n| `light` | `turn_on`, `turn_off`, `toggle` | `light.kitchen` |\n| `switch` | `turn_on`, `turn_off`, `toggle` | `switch.fan` |\n| `climate` | `set_temperature`, `set_hvac_mode` | `climate.thermostat` |\n| `cover` | `open_cover`, `close_cover`, `stop_cover` | `cover.garage` |\n| `media_player` | `play_media`, `media_pause`, `volume_set` | `media_player.tv` |\n| `scene` | `turn_on` | `scene.relax` |\n| `script` | `turn_on` | `script.welcome_home` |\n| `automation` | `trigger`, `turn_on`, `turn_off` | `automation.sunrise` |\n\n## Inbound Webhooks (HA → Clawdbot)\n\nTo receive events from Home Assistant automations:\n\n### 1. Create HA Automation with Webhook Action\n\n```yaml\n# In HA automation\naction:\n  - service: rest_command.notify_clawdbot\n    data:\n      event: motion_detected\n      area: living_room\n```\n\n### 2. Define REST Command in HA\n\n```yaml\n# configuration.yaml\nrest_command:\n  notify_clawdbot:\n    url: \"https://your-clawdbot-url/webhook/home-assistant\"\n    method: POST\n    headers:\n      Authorization: \"Bearer {{ webhook_secret }}\"\n      Content-Type: \"application/json\"\n    payload: '{\"event\": \"{{ event }}\", \"area\": \"{{ area }}\"}'\n```\n\n### 3. Handle in Clawdbot\n\nClawdbot receives the webhook and can notify you or take action based on the event.\n\n## CLI Wrapper\n\nThe `scripts/ha.sh` CLI provides easy access to all HA functions:\n\n```bash\n# Test connection\nha.sh info\n\n# List entities\nha.sh list all          # all entities\nha.sh list lights       # just lights\nha.sh list switch       # just switches\n\n# Search entities\nha.sh search kitchen    # find entities by name\n\n# Get/set state\nha.sh state light.living_room\nha.sh states light.living_room   # full details with attributes\nha.sh on light.living_room\nha.sh on light.living_room 200   # with brightness (0-255)\nha.sh off light.living_room\nha.sh toggle switch.fan\n\n# Scenes & scripts\nha.sh scene movie_night\nha.sh script goodnight\n\n# Climate\nha.sh climate climate.thermostat 22\n\n# Call any service\nha.sh call light turn_on '{\"entity_id\":\"light.room\",\"brightness\":200}'\n```\n\n## Troubleshooting\n\n- **401 Unauthorized**: Token expired or invalid. Generate a new one.\n- **Connection refused**: Check HA_URL, ensure HA is running and accessible.\n- **Entity not found**: List entities to find the correct entity_id.\n\n## API Reference\n\nFor advanced usage, see [references/api.md](references/api.md).\n","topics":["Rest Api","Smart Home","Webhook"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":21357,"installsAllTime":684,"installsCurrent":245,"stars":49,"versions":1},"createdAt":1769638965135,"updatedAt":1779076502752},"latestVersion":{"version":"1.0.0","createdAt":1769638965135,"changelog":"Initial release: Control HA devices, scenes, scripts via REST API + webhook support","license":null},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"iahmadzain","userId":"s17cf34jbena7tkcp6ed042bzh884fx4","displayName":"iAhmadZain","image":"https://avatars.githubusercontent.com/u/9432748?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1779917516799}}