Incase anyone is interested I made a Shortcut that toggles the state of an Home Assistant Entity between ON/Off using the Home Assistant API.
You can get a Home Assistant API Token by going your Profile Page when logged in to Home Assistant and then scrolling to the bottom and clicking “Create Token”. Answer the setup questions or read the comments to setup the Shortcut.
Hope this helps someone.
Please let me know if you have any questions.
Very cool indeed. For anyone trying this, I found several useful items of info by trial and error using the Postman API dev tool and the Home Assistant API documentation https://developers.home-assistant.io/docs/api/rest/:
- The Home Assistant network address will default to http://homeassistant.local:8123
- Prefix your Home Assistant Authorization Token with the text 'Bearer ’ (note the space before the Token text.
- Get your Entity ID when logged into the Home assistant console via Settings > Devices & Services > Entities tab. You will see the Entity ID column.
- I would choose a light bulb to test the Shortcut
This opens up a lot of possibilities. Thank you very much for sharing this Aidan.
Thanks! I updated the Shortcut to include the essential setup information you mentioned. Great advice, thank you!!
FYI, you can skip the state check by using the
toggle service that
switch entity types support. It’ll handle figuring out whether to turn the light on or off for you.
You can even simplify this shortcut further if you have the Home Assistant app installed on your Mac or iPhone/iPad. It has several Shortcut actions, including
Ahhhh thats how that works… thank you thank you thank you!!