It's actually fairly easy to control Home Assistant remotely using curl
but I couldn't find a complete solution on how to do this, so here goes...
- Activate the api in
configuration.yaml
by adding the lineapi:
- Get an Authorization token from HA (It's a Long-Lived Access Tokens which can be created on your HA user profile page)
- This list of exposed states can be found using
curl -X GET -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" http://YOUR_IP:8123/api/states | prettyjson
- Note
prettyjson
is an alias forpython -m json.tool
, you don't need this it's just easier to read.
- To get the state of a device append the entity.id to the URL, eg
curl -X GET -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" http://YOUR_IP:8123/api/states/switch.mylight | prettyjson
- The API documentation shows you how to change the states but this does not actually turn on the lights, etc. Instead, us