Fresh start - excluded large ROM JSON files
This commit is contained in:
65
skills/home-assistant/SKILL.md
Normal file
65
skills/home-assistant/SKILL.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
name: home-assistant
|
||||
description: Interact with a Home Assistant instance via its REST API. Use to query entity states, control devices, and manage automations. Requires HA URL and long-lived access token via environment variables HA_URL and HA_TOKEN.
|
||||
---
|
||||
|
||||
# Home Assistant Skill
|
||||
|
||||
This skill enables interaction with a Home Assistant instance through its REST API.
|
||||
|
||||
## Configuration
|
||||
|
||||
Set these environment variables:
|
||||
- `HA_URL` - Home Assistant URL (e.g., `http://192.168.0.39:8123` or `https://your-ha.com`)
|
||||
- `HA_TOKEN` - Long-lived access token from HA Profile > Security > Create Token
|
||||
|
||||
## Common Commands
|
||||
|
||||
### Get All States
|
||||
```
|
||||
GET /api/states
|
||||
```
|
||||
Returns all entity states. Useful for overview.
|
||||
|
||||
### Get Specific Entity
|
||||
```
|
||||
GET /api/states/<entity_id>
|
||||
```
|
||||
Example: `/api/states/climate.living_room`
|
||||
|
||||
### Control Device (turn_on, turn_off, toggle, etc.)
|
||||
```
|
||||
POST /api/services/<domain>/<service>
|
||||
Body: {"entity_id": "<entity_id>"}
|
||||
```
|
||||
Example - turn on a light:
|
||||
```
|
||||
POST /api/services/light/turn_on
|
||||
Body: {"entity_id": "light.kitchen_lights"}
|
||||
```
|
||||
|
||||
### Call Climate Service
|
||||
```
|
||||
POST /api/services/climate/set_temperature
|
||||
Body: {"entity_id": "climate.living_room", "temperature": 72}
|
||||
```
|
||||
|
||||
## API Endpoints Reference
|
||||
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/states` | GET | All entity states |
|
||||
| `/api/states/<entity_id>` | GET | Single entity state |
|
||||
| `/api/config` | GET | HA configuration |
|
||||
| `/api/history/period/<timestamp>` | GET | State history |
|
||||
| `/api/logbook/<timestamp>` | GET | Logbook entries |
|
||||
|
||||
## Domains
|
||||
|
||||
Common domains: `light`, `switch`, `climate`, `cover`, `media_player`, `automation`, `script`, `input_boolean`, `sensor`
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `/api/states` first to discover entity IDs
|
||||
- Entity IDs are lowercase with underscores: `light.living_room`
|
||||
- Services like `turn_on` support additional attributes: `{"entity_id": "light.kitchen", "brightness": 255}`
|
||||
59
skills/home-assistant/references/commands.md
Normal file
59
skills/home-assistant/references/commands.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Home Assistant Quick Reference
|
||||
|
||||
## Query Examples
|
||||
|
||||
### Get all entities
|
||||
```bash
|
||||
export HA_URL="http://192.168.0.39:8123"
|
||||
export HA_TOKEN="your-token"
|
||||
./ha-api.sh /api/states GET
|
||||
```
|
||||
|
||||
### Get single entity
|
||||
```bash
|
||||
./ha-api.sh /api/states/climate.living_room GET
|
||||
```
|
||||
|
||||
### Get weather
|
||||
```bash
|
||||
./ha-api.sh /api/states/weather.home GET
|
||||
```
|
||||
|
||||
## Control Examples
|
||||
|
||||
### Turn on light
|
||||
```bash
|
||||
./ha-api.sh /api/services/light/turn_on POST '{"entity_id": "light.kitchen"}'
|
||||
```
|
||||
|
||||
### Turn off switch
|
||||
```bash
|
||||
./ha-api.sh /api/services/switch/turn_off POST '{"entity_id": "switch.garage_door"}'
|
||||
```
|
||||
|
||||
### Set thermostat temperature
|
||||
```bash
|
||||
./ha-api.sh /api/services/climate/set_temperature POST '{"entity_id": " climate.living_room", "temperature": 72}'
|
||||
```
|
||||
|
||||
### Toggle garage door
|
||||
```bash
|
||||
./ha-api.sh /api/services/cover/toggle POST '{"entity_id": "cover.garage_door"}'
|
||||
```
|
||||
|
||||
## Useful Entity Queries
|
||||
|
||||
### List all lights
|
||||
```bash
|
||||
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*light[^"]*"'
|
||||
```
|
||||
|
||||
### List all climate devices
|
||||
```bash
|
||||
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*climate[^"]*"'
|
||||
```
|
||||
|
||||
### List all sensors
|
||||
```bash
|
||||
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*sensor[^"]*"'
|
||||
```
|
||||
27
skills/home-assistant/scripts/ha-api.sh
Normal file
27
skills/home-assistant/scripts/ha-api.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Home Assistant API helper script
|
||||
# Usage: ./ha-api.sh <endpoint> [method] [body]
|
||||
|
||||
HA_URL="${HA_URL:-http://localhost:8123}"
|
||||
HA_TOKEN="${HA_TOKEN:-}"
|
||||
|
||||
if [ -z "$HA_TOKEN" ]; then
|
||||
echo "Error: HA_TOKEN not set. Export HA_TOKEN first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ENDPOINT="$1"
|
||||
METHOD="${2:-GET}"
|
||||
BODY="${3:-}"
|
||||
|
||||
if [ -n "$BODY" ]; then
|
||||
curl -s -X "$METHOD" \
|
||||
-H "Authorization: Bearer $HA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$BODY" \
|
||||
"$HA_URL$ENDPOINT"
|
||||
else
|
||||
curl -s -X "$METHOD" \
|
||||
-H "Authorization: Bearer $HA_TOKEN" \
|
||||
"$HA_URL$ENDPOINT"
|
||||
fi
|
||||
Reference in New Issue
Block a user