Toggling the State of a Home Assistant Entity via Shortcuts

Hey Everyone,

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.

https://www.icloud.com/shortcuts/b666b697251b4c19a33f4725cb2f2b00

Hope this helps someone.

Please let me know if you have any questions.

Aidan :slight_smile:

1 Like

Hi Aidan,

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/:

  1. The Home Assistant network address will default to http://homeassistant.local:8123
  2. Prefix your Home Assistant Authorization Token with the text 'Bearer ’ (note the space before the Token text.
  3. Get your Entity ID when logged into the Home assistant console via Settings > Devices & Services > Entities tab. You will see the Entity ID column.
  4. 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!!

https://www.icloud.com/shortcuts/c1a5a976c6a74a2f8fe494e3d7a4cb6b

FYI, you can skip the state check by using the toggle service that light and 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 Call Service.

1 Like

Ahhhh thats how that works… thank you thank you thank you!! :+1::man_facepalming: