This post may contain affiliate links. Please see our disclaimer for more info.
Next up on our quick tips; using Node Red Automations to handle iOS Action events. The action events are the quick buttons that iOS provides either via a widget, long press on the HA icon, or even on an Apple watch if you have one. With this, you’ll be able to implement iOS actions with ease making it very quick to perform events.
Use Node Red automation to handle iOS action button presses to trigger HA actions. See my Node Red export here.
The action event
iOS companion sends out an ios.action_fired event when an action button is pressed. These events provide a string which we can decipher in HA and use this to trigger other events. This means that all the logic of the action button lies in Home Assistant Automations and there is no logic for this in the iOS app.
Unfortunately, there isn’t a way to set service calls within the iOS app itself – this would make this process simpler (perhaps more difficult to implement). On the plus side, having all the logic in HA makes it easy to set up other iOS devices to use the same actions without having to reconfigure all the steps.
All the iOS action button logic lies in Home Assistant automations – not the iOS app.
The ios.action_fired event provides a few details: namely the action name and what device sent the action. I’m only using the action name, but you could use the sending device name to customize automations event further to be device/person specific.
Automating in Node Red
The process is pretty simple once we break it down:
- listen for ios.action_fired events
- use a switch node to determine which event was fired
- send the message (or think of it as a procedure call) to the proper nodes to continue the automation
If you’re not familiar, the switch node (what I have named action coordinator) is pretty slick. It picks up various parts of a message (the data object that node red passes around) and will direct the message to various outputs depending on what filters you’ve set up. All it is doing is looking for the action name and then pumping it through to the proper output.
In my setup (see screenshot below), my first and third automations are pretty simple. They are just calling various services:
- Sleep time triggers that everyone is in bed and turns of all interior lights.
- Cats Water triggers a reset of a counter that I’ve set up to track when the cats need fresh water – see this post here for details.
The middle one, Garage Door, is a bit more complicated… it triggers my garage door to open/close. I use an OpenGarage unit which integrates nicely with HA. As a safeguard, I built in functionality using nodes that requires the action to be called twice within 5 seconds in order for the door to be triggered. This is to prevent accidental presses and opening up the garage unintentionally.
Find my Node Red export here.
While it’s a few nodes and looks a little messy, I’m quite pleased with 1) being able to do this with just nodes and 2) it works flawlessly. I may try to simplify things a bit or move it into it’s own sub flow, but for now… if it’s not broke, don’t fix it.
Adding additional actions is now as simple as adding more filters and outputs to the switch node. Just get the action names aligned between node red and the iOS app and the rest will take care of itself!
Hope this was helpful – please comment with any questions or request for more details!