Trigger Siri shortcut from HA

There is no direct way but a workaround.
To run personal automations in shortcuts on iOS:

Create a dummy switch in home assistant (or dummy powerstrip if you want to run more shortcuts) and add it to your HomeKit bridge.

Have an automation in home assistant be triggered by the changed state of the previously named switch and then have the same automation send an email with a specific subject using SMTP integration from home assistant.

In shortcuts create a personal automation that checks your email for a new email from a certain sender with a certain subject and then have it run any shortcut you’d like.

1 Like

I’m wondering if it really is a technical need, that we click on the notification to start a shortcut.

I bet behind the scene, a callback in the app is executed in the background that starts the shortcut.
As we already have silent notifications (this doesn’t mean no sound. It’s the term Apple uses for notifications that aren’t visible to the user, but allow the app to run a few seconds in the background. HA Companion already uses this e.g. for clearing the badge using a notification):

Wouldn’t it be possible to use a new message-identifier together with the shortcut key in the message data to run a shortcut?
For thing that doesn’t need user interaction like changing iOS focus settings …

Executing a shortcut requires launching the Shortcuts app which cannot be done in the background.

1 Like

Email trigger on iPhone is not able to run without notification and confirm. You will still get a notification without any specific information from Shortcuts app.

1 Like

PushCut app is able to achieve some of our goals, but it requires another iOS device as a server and always-on (app runs on front). When it becomes a server it shows all black… And there is nothing we can use with that part of black screen.
But when Home Assistant app runs on front, it could be a dashboard! I wish one day Home Assistant iOS Companion App could add this feature.

I’m using HA’s ssh integration combined with the macOS shortcuts shell command to, among other things, run an always-on Mac as a Shortcuts server. It works reliably to subvert confirmation messages and all the other folderol for which I previously relied on Pushcuts, IFTT, etc.

The shortcuts command is just one possibility: HA can send whatever shell commands you like to any remote Mac, sending either a complete command, or for more complex applications, executing a script on the remote Mac. So far as Shortcuts (or any other app) is concerned, it’s all being run on the Mac, which subverts most if not all of Apple’s security nannying.

The only tricky part is implementing key pair encryption for secure password-free access to the Mac on the HA host. Key generation and installing HA’s public key on the Mac is as usual, but the HA server requires some fancy footwork. First, because most installations run Home Assistant in a container rather than directly on the host, and keys have to be accessible from within the container, not just on the host. Second, since HA updates have the potential to wipe out everything but the config directory, there’s little point installing anything anywhere else.

Handily, both problems have a single, straightforward solution: on the HA side, implement keys and known_hosts in a subdirectory of /config/. (I use /config/.ssh for consistency, but it’s arbitrary, provided you make sure the directory and its contents have the correct permissions.) Then specify the HA key and known hosts file to be used in the command itself.

ssh \
   -i /config/.ssh/id_rsa \
   -o UserKnownHostsFile=/config/.ssh/known_hosts \ 
   [email protected] \
   /usr/bin/shortcuts "Vacuum the Dog House"

Note: The above use of \ to split the command into lines for readability won’t work in a HA’s YAML, so put it all on one line.

Multiple commands can be combined using the usual 'nix ; and &&, or created as individual entries in /config/.

Once set up, any script or automation can execute anything on the remote Mac simply by calling the desired command as an SSH service. HA can tell the Mac to do pretty much anything that’s executable from the command line and doesn’t require interaction. I’m experimenting with Shortcuts, AppleScript, and shell scripts, all with good results. My only complaint is that there appears to be no way to get HA to load changes to the shell_command: configuration without restarting the server.

1 Like

There are so many more sensors and options available in Android than iOS, it’s more a question of what can’t you do.

You also have notification commands that allow you to more or less anything on the phone, e.g. make a phone call.

As just a few examples:

I use sensor.phone_state for lots of different things, like announcing my phone is ringing on my Echo speakers in case I am in another room, pausing the TV when a call comes in etc.

I use the bluetooth sensors to tell when I am getting into and out of my car (and when I am in it) and various other things like if my wallet has been left behind.

I use sensor.next_alarm to know when I am getting up each day.

The battery sensors actually work properly on Android, unlike on iOS which only sends updates when it arbitrarily decides it wants to due to restricted background processes. I use these to announce on my Echo speakers my phone has reached full charge when it’s come from a low charge level, so I don’t need to keep checking to see if it’s full and to remind me to charge my phone when I come home and the battery is low.

1 Like

When Local Push is enabled (e.g. when you are on Wi-Fi and have Local Push turned on) the app will update the sensors relatively immediately for things like battery state, so for at least the case of “when is charge finished?” you can determine that.

But at the end of the day, iOS is significantly less capable than Android when it comes to allowing third party apps to do things. Unfortunately until and unless we get permission to do things, Sandbox restrictions prevent the app from doing fun things like e.g. running a Shortcut from the background.

The macOS app could run Shortcuts though, and that’s something that could be added.

1 Like

And this is why I don’t understand why anyone using Home Assistant would choose iOS over Android. You’re sacrificing so much functionality.

Easy, had an iPad laying around doing nothing and a android is something I need to buy.

1 Like