59 lines
1.2 KiB
Markdown
59 lines
1.2 KiB
Markdown
# 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[^"]*"'
|
|
``` |