Skill 详情
home-assistant
Direct Home Assistant monitoring and REST API device-control skill.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
---
name: home-assistant
description: Control and monitor your smart home with Home Assistant. Get device states, call services to control lights/switches/climate, fire events, and query history. Use when the user asks about smart home, Home Assistant, lights, switches, sensors, thermostats, automation, or home control.
license: MIT
metadata:
author: agentskills
version: "1.0.0"
api_provider: home-assistant.io
allowed-tools: Bash(node:*)
---
# Home Assistant Smart Home Control
Control and monitor your smart home through the Home Assistant REST API. Manage lights, switches, sensors, climate controls, and automations.
## Prerequisites
Before using this Skill, you must:
1. Install Node.js dependencies:
```bash
cd scripts && npm install && npm run build
```
2. Have a running Home Assistant instance accessible via HTTP/HTTPS
3. Generate a Long-Lived Access Token (see [references/SETUP.md](references/SETUP.md))
4. Set environment variables:
```bash
export HOME_ASSISTANT_URL="http://your-home-assistant:8123"
export HOME_ASSISTANT_TOKEN="your-long-lived-access-token"
```
## Instructions
### Getting Entity States
To retrieve current state of all entities or a specific entity:
```bash
node scripts/dist/get-states.js
```
**Options:**
- `--entity <id>` or `-e` - Get state of specific entity
**Examples:**
Get all entity states:
```bash
node scripts/dist/get-states.js
```
Get specific entity state:
```bash
node scripts/dist/get-states.js --entity light.living_room
node scripts/dist/get-states.js -e sensor.temperature
```
Filter entities by type:
```bash
node scripts/dist/get-states.js | jq '.[] | select(.entity_id | startswith("light."))'
```
**Entity State includes:**
- `entity_id` - Unique identifier (e.g., "light.living_room")
- `state` - Current state ("on", "off", "23.5", etc.)
- `attributes` - Entity-specific attributes (brightness, temperature, etc.)
- `last_changed` - When state last changed
- `last_updated` - When entity was last updated
### Calling Services
To control devices and trigger automations:
```bash
node scripts/dist/call-service.js --domain <domain> --service <service> [options]
```
**Required:**
- `--domain <domain>` or `-d` - Service domain (light, switch, climate, etc.)
- `--service <name>` or `-s` - Service name (turn_on, turn_off, toggle, etc.)
**Optional:**
- `--entity <id>` or `-e` - Target entity ID
- `--data <json>` - Additional service data as JSON
**Common Domains and Services:**
| Domain | Services |
|--------|----------|
| light | turn_on, turn_off, toggle |
| switch | turn_on, turn_off, toggle |
| scene | turn_on |
| script | turn_on, turn_off, toggle |
| cover | open_cover, close_cover, stop_cover |
| climate | set_temperature, set_hvac_mode |
| media_player | play_media, pause, stop, volume_set |
| automation | trigger, turn_on, turn_off |
**Examples:**
Turn on a light:
```bash
node scripts/dist/call-service.js -d light -s turn_on -e light.living_room
```
Turn off a switch:
```bash
node scripts/dist/call-service.js -d switch -s turn_off -e switch.bedroom_fan
```
Activate a scene:
```bash
node scripts/dist/call-service.js -d scene -s turn_on -e scene.movie_time
```
Turn on light with brightness:
```bash
node scripts/dist/call-service.js -d light -s turn_on -e light.bedroom --data '{"brightness": 128}'
```
Set thermostat temperature:
```bash
node scripts/dist/call-service.js -d climate -s set_temperature -e climate.thermostat --data '{"temperature": 72}'
```
Toggle multiple lights:
```bash
node scripts/dist/call-service.js -d light -s toggle --data '{"entity_id": ["light.kitchen", "light.dining"]}'
```
Set light color:
```bash
node scripts/dist/call-service.js -d light -s turn_on -e light.rgb_strip --data '{"rgb_color": [255, 0, 0]}'
```
### Getting Configuration
To retrieve Home Assistant system configuration:
```bash
node scripts/dist/get-config.js
```
**Options:**
- `--components` or `-c` - List only loaded components/integrations
**Configuration includes:**
- 在 GitHub 阅读完整来源 (打开外部页面)