I haven’t seen anyone post about using the new shortcuts app to control Home Assistant so I figured I would share my progress with it here in case there was any interest withing the community. This is one out of the five projects that I hope to share this month. I’m sure there’s other ways of making shortcuts that talk to HA but this is just what I’ve personally tested so far and know works.
Big thanks to @DrZzs for helping me test this without SSL!
To get started download the Shortcuts App on your iOS device
Once you have it installed and ready open it up and click Create Shortcut.
Now we’re ready to create our first shortcut! We’ll start off with an easy Service Call to toggle a light using the Rest API!
Toggling the state of an entity
-
Tap the search button and then type in URL.
-
Fill in the URL to match your HA address and service call.
Examples:
https://yourhomeassistanturl.com/api/services/light/toggle http://yourexternalip:8123/api/services/light/toggle
- Then click the search bar again and this time type in Get Contents of URL.
- Once you have the new block added click Adavnced and change the Method type to POST.
- After that click on Headers and add a new header.
- Change the name of the key block to Authorization
- Change the name of the text block to Bearer your long-lived access token
Example:
Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwMTg1blahblahblah
- Then in the Request Body click add new field and select text.
- Change the name of the key block to entity_id
- Change the name of the text block to match the name of the light you would like to toggle.
And that’s it… If you just wanna toggle Lights, Switches, Input Booleans, etc…
If you also want to receive the state back of the entity of choice then follow the rest of this tutorial. If you just care about turning stuff on and off then just leave now and go have fun with your new shortcuts.
Receiving the state of an entity
Follow these screenshots if you would like to also receive the state of the entity.
I will update this tutorial with written documentation tomorrow but for now I will just post the screenshots as at this point you should have the idea of how to do this.
Add the shortcut to Siri or the home screen
If you would like to be able to control your new shortcut with Siri or from the home screen then click the icon at the top right and click either add to sir, add to home screen, or both.