1.2 KiB
1.2 KiB
Home Assistant Quick Reference
Query Examples
Get all entities
export HA_URL="http://192.168.0.39:8123"
export HA_TOKEN="your-token"
./ha-api.sh /api/states GET
Get single entity
./ha-api.sh /api/states/climate.living_room GET
Get weather
./ha-api.sh /api/states/weather.home GET
Control Examples
Turn on light
./ha-api.sh /api/services/light/turn_on POST '{"entity_id": "light.kitchen"}'
Turn off switch
./ha-api.sh /api/services/switch/turn_off POST '{"entity_id": "switch.garage_door"}'
Set thermostat temperature
./ha-api.sh /api/services/climate/set_temperature POST '{"entity_id": " climate.living_room", "temperature": 72}'
Toggle garage door
./ha-api.sh /api/services/cover/toggle POST '{"entity_id": "cover.garage_door"}'
Useful Entity Queries
List all lights
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*light[^"]*"'
List all climate devices
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*climate[^"]*"'
List all sensors
./ha-api.sh /api/states GET | grep -o '"entity_id": "[^"]*sensor[^"]*"'