Great New Homekit Connection – Homekit Can Trigger Keyboard Maestro

I just came across this, not sure how long it’s been possible, but I didn't find it mentioned elsewhere:

Homekit automations can trigger KM Macros! this was a serious missing link for me.

(I’ve seen Type to Siri, for activating Homekit actions. This is the other direction - making devices in your home trigger new actions - of greater capabilities than Apple’s standard issue)

I was frustrated when first exploring homekit automation that they couldn’t fire off an applescript. Mostly they invoke a homekit “scene”. From the Home app, they can also trigger a limited subset of “siri shortcuts”. BUT, crucially one of the few allowed actions is:

And that URL can be… (drum roll) the URL of a KM macro. not the "kmtrigger://macro" style, but the URL for triggering the macro via the web server on your mac. The URL is being accessed by a homekit “hub” device such as a homepod, or appletv. So it can see your mac on the local network. I used a local macro URL, but you could also use the external macro URL (RIP Peter’s servers…).

So by having the automation get this local address:

http://192.168.2.7:4490/action.html?macro=4BDAC38F-41D6-4F35-8014-7FD0717F1118

I now get this:

Untitled

I first learned of ‘Get URL’ in homekit from the app, Pushkit. which does about the same thing - accepts a homekit trigger URL on their server, which then can re-direct to fully capable shortcuts.

Are we approaching the KM-Homekit-Singularity?

3 Likes

@avialan -

You can also use Run Script over SSH Siri Action to trigger a KM macro using a username/ password combination with a:

osascript -e '
tell application "Keyboard Maestro Engine"
   do script "8A9042AB-81E0-498E-AFEC-A772B6F94CA8"
end tell
'

I've been using it for quite a while. Many, many things are possible with the KM/Shortcut/HomeKit integration.

Good luck!

4 Likes

Ah, of course! That's even more flexible. I had used ssh scripting in the past, but I didn't notice the command among homekit's limited vocabulary.