--- name: home-assistant description: 'Control smart home devices and query Home Assistant. Use when the user asks to control lights, switches, media players, covers, climate, sensors, or any smart home entity. Also use for scenes, scripts, automations, and device state queries. Examples: turn off the living room lights, what is the temperature in the bedroom, play music in the kitchen, is the front door locked.' --- # Home Assistant Skill ## Connection - URL: http://10.0.0.199:8123 - Token: read from environment `HASS_TOKEN` or file `~/.homeai/hass_token` - API base: `{URL}/api` ## Common API calls **Get all states (entity discovery):** ```bash curl -s -H "Authorization: Bearer $HASS_TOKEN" \ http://10.0.0.199:8123/api/states | jq '[.[] | {entity_id, state, attributes: .attributes.friendly_name}]' ``` **Get single entity state:** ```bash curl -s -H "Authorization: Bearer $HASS_TOKEN" \ http://10.0.0.199:8123/api/states/ ``` **Call a service (turn on/off, set value, etc.):** ```bash curl -s -X POST \ -H "Authorization: Bearer $HASS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"entity_id": ""}' \ http://10.0.0.199:8123/api/services// ``` ## Domain/service reference | Domain | Services | |---|---| | light | turn_on, turn_off, toggle (+ brightness, color_temp, rgb_color) | | switch | turn_on, turn_off, toggle | | media_player | media_play, media_pause, media_stop, volume_set, select_source | | cover | open_cover, close_cover, set_cover_position | | climate | set_temperature, set_hvac_mode | | scene | turn_on | | script | turn_on | | input_boolean | turn_on, turn_off, toggle | | homeassistant | turn_on, turn_off (works across domains) | ## Workflow 1. If entity ID is unknown, GET /api/states and filter by friendly_name or domain 2. Call the appropriate service with the entity_id 3. Confirm the action succeeded (HTTP 200 = OK) 4. Report back to user in natural language ## Tips - Entity IDs follow pattern: `.` e.g. `light.living_room` - For brightness: 0–255 range (255 = max) - Token is long-lived — never regenerate unless asked