Launch iOS Shortcut on an iOS device from a Mac using KM

This started out as a question but I figured out a solution while typing it up.

I also found this question from a few years ago, with no solutions.

I wanted to launch an iOS Shortcut using KM because KM's criteria handling is way more flexible than Shortcuts's. Here's why I need to do it in such a convoluted way.

Tesla's app for iOS just allowed for Shortcuts integration.
Mac has Shortcuts, and I can install some iOS apps on my Mac, but Tesla's app is not one of them. Otherwise, I could just use KM to launch a Shortcuts on my Mac to do this.

I wanted to set up this workflow:
Using KM: if I'm at work (I can get this info using KM from e.g. my IP address and other methods), and the temperature is above X, activate the Shortcut on my phone at lunchtime.

Using Shortcuts on iOS: The Shortcut is on my phone, and simply vents my car (open all windows slightly) and turn on the AC.

One way for my Mac to "communicate" to Shortcuts on my iPhone:

  1. I set up the KM macro on my Mac to run on weekdays at 1:25pm, and write a "true/false" text string to a text file in my iCloud > Shortcuts folder based on my criteria. e.g. the filename is okToVent.txt, and if the temperature outside is above X, write a "true" to the file.

  2. On my iPhone, I set up an Automation to run daily at 1:30pm. It reads the okToVent.txt file, and if it contains "true", run the actions (open the windows and turn on the AC).

This is a pretty simple way to "send" a directive from a Mac to an iPhone.


You can also use the “when I get an email” automation on iOS. Then pass the email’s content to the shortcut (available through “shortcut input”). You could email yourself some JSON and then parse it in the shortcut and act accordingly.


Cool solution, literally and figuratively. Wondering how you handle rain? If it is warm enough to lower the windows but it is raining.

I'm using Shortcuts in conjunction with KM to get the weather. It doesn't rain much here, especially when it's hot, but I suppose I could use KM to interpret the info from the Weather app and change the if/then accordingly. Or maybe add a "I'm going to vent the windows, are you sure you want to continue?" input.

There's a lot of flexibility here with using Shortcuts (Mac) as the input, KM to handle the "logic", then Shortcuts (iOS) to deal with the output. I love that about KM; you can connect so many different things to it.

The Macro below uses a submacro but I didn't include it because it's pretty obvious YMMV. I'm including it here so you can see the simple flow.

vent car at work when hot.kmmacros (7.7 KB)

PushCut on iOS might be helpful here. Avoids the latency of a timed shortcut.

1 Like

Hi, @edjusted. Thanks for sharing your technique and macro. Cool stuff! Pun intended. :grinning:

Since you are are integrating Shortcuts with Keyboard Maestro, you might find this thread interesting: Keyboard Maestro and macOS Shortcuts—Data Transfer Examples - Tips & Tutorials

1 Like

Not a KM solution, but as a Home Assistant user, I have the HomeKit integration for triggering shortcuts on the phone. You can set up 'dummy' temp sensor which (when you change the temp) will trigger shortcut automations on your iOS device.

A Shortcuts-only solution is straight forward for this case, if a simpler set up is ever needed. I've had intermittent issues with Shortcuts writing to files or having one part of a two-step automation fail, so I try to keep to one tool at a time, if possible.

In this case, set an automation for the desired schedule and have it run a Shortcut that checks location and weather. This example uses GPS location but network connection is any easy alternative.

Oh, thanks. I'm much better with KM than Shortcuts, so that's mainly why I went in that direction (plus I think building Shortcuts is kind'a clunky), but I like how self-contained this is, and the "distance from work" is probably a lot more accurate than my current method.