Use Siri Shortcuts In HomeKit Automations

While HomeKit offers a good selection of common home automation capabilities, sometimes you want a little more logic complexity than you can achieve with just triggers and conditions.

There are third party options to drive some of this automation behavior, but with iOS 13 Apple quietly added the ability to forgoe the normal rule creation and instead convert automations to Shortcuts.

This is a bit of a mixed blessing because the available Shortcuts commands are limited to what can be run from a home hub, which negates anything to do with third party apps, user input, or displaying results. It would be nice to generate custom notifications using this feature, but for some reason even sending a standard iOS notification is not available.

Even so, you can use the full scripting set and various other useful tools, and can access your HomeKit accessory state and send commands to them. This means you can essentially create a host of automation rules not normally possible in a HomeKit client app. Combined with other advanced HomeKit automation techniques it’s possible to significantly open up the possibilities for your smart home.

How to convert an automation to a shortcut

Accessing Shortcut functionality in your automations is quite simple, but not obvious. When creating a new automation (you need to do this in the Home app, not a third party one), create a trigger as normal, be it People, Time, or Accessory/Sensor state.

Next, on the screen where you would normally select scenes and accessories to control, scroll all the way to the bottom where you’ll see a button called Convert to Shortcut.

Tap that and you’ll be taken to a version of the Shortcut editor. This works in a similar way to the full Shortcuts app, but with the limitations noted above.

You’ll see from the list above that there are some actions of particular interest, such as If, Wait, and Repeat. These overcome the lack of complex rules in normal HomeKit automations to a significant extent. With this you can create more complex conditional behaviors and delayed actions.

The ability to extract data returned from web queries and perform numeric calculations also stand out as very useful for creating more deterministic rules instead of static values.

In particular, the ability to run a script over SSH opens up some very interesting possibilities for more advanced users that want to interface with their own server-based solutions or third-party integration tools.

If you are looking to take your HomeKit set up to the next level, this added layer of control is well worth exploring.

Some Home App Shortcut Examples

 

A Toggle Button

This is a simple shortcut that allows you to create and on/off switch from a single button, rather than having to waste an extra button for the off action.

I’ve detailed this one in my HomeKit toggle switch tutorial if you want to see how to find the button actions.

This shortcut reads the current state of the accessory you want to turn on or off, then does the opposite action using an ‘If‘ control flow.

This can be used for any on/off type accessory, such as smart outlets, smart fans, or smart lights. This example is using a Meross smart plug to control a pedestal fan from one of the buttons on a Hue Tap switch.

A screenshot of a toggle switch shortcut in the Apple Home app.
 

Turn off the AC if the window is left open

Another simple shortcut that is triggered by a window or door opening. It simply waits for 5 minutes, then checks if that door or window is still open. If it is, it turns off the AC.

I created this one as we will always leave our sliding door open if we want to get fresh air through the house, and the kids can tend to leave it open as well.

It’s not fool-proof since the door might happen to be open at the exact moment the shortcut checks it again, but it’s reliable enough 99% of the time.

You’ll need a contact sensor and a HomeKit compatible thermostat or AC controller. I’m using an Eve Door/Window sensor coupled to a Sensibo Aiq Q for this one.

What Shortcut Actions are available?

Similar to the full Siri Shortcuts app the actions are split into two sections: Categories and Apps.

Under Categories you’ll find four groupings: Scripting, Location, Documents, and Web. Below is a complete list of all available actions in these categories for easy reference.

Scripting Category Actions

All Scripting Actions in the Home app

 
  • Control Flow

    • If

    • Repeat

    • Repeat for Each

    • Stop and Output

    • Stop This Shortcut

    • Wait

  • Device

    • Get Device Detaills

  • Dictionaries

    • Dictionary

    • Get Dictionary from Input

    • Get Dictionary Value

  • Files

    • Base64 Encode

    • Generate Hash

  • Items

    • Count

    • Get Name

    • Get Type

    • Set Name

  • Lists

    • Get Item from List

    • List

  • Maths

    • Calculate

    • Calculate Expression

    • Round Number

  • Measurements

    • Convert Measurement

    • Measurement

  • Network

    • Get Current IP Address

    • Get Network Details

  • No-ops

    • Comments

    • Nothing

  • Numbers

    • Format Number

    • Get Numbers from Input

    • Number

    • Random Number

  • Shell

    • Run Script over SSH

  • Variables

    • Add to Variable

    • Get Variable

    • Set Variable

  • X-Callback

    • URL Encode


Location Category Actions

All Location Actions in the Home app

  • Filter Locations

  • Get Current Location

  • Get Details of Locations

  • Location

  • Addresses

    • Get Addresses from Input

    • Street Address

  • Routing

    • Find Places

    • Get Distance

    • Get Halfway Point

    • Get Travel Time

  • Weather

    • Get Current Weather

    • Get Details of Weather Conditions

    • Get Weather Forecast


Documents Category Actions

All Document Actions in the Home app

 
  • Archives

    • Make Archive

  • Files

    • Get Details of Files

  • Printing

    • Make PDF

  • QR Codes

    • Generate QR Code

  • Rich Text

    • Make MHTL from Rich Text

    • Make Markdown from Rich Text

    • Make Rich Text from HTML

    • Make Rich Text from Markdown

  • Text

    • Extract Text from Image

    • Get Name of Emoji

    • Get Text from Input

    • Text

  • Text Editing

    • Change Case

    • Combine Text

    • Correct Spelling

    • Get Group from Matched Text

    • Match Text

    • Replace Text

    • Split Text


Web Category Actions

All Web Actions in the Home app

  • RSS

    • Get Items from RSS Feed

    • Get RSS Feeds from Page

  • URLs

    • Expand URL

    • Get Component of URL

    • Get URLs from Input

    • URL

  • Web Requests

    • Get Contents of URL

    • Get Contents of Web Page

    • Get Headers of URL


Apps Shortcut Actions

 

Additional to the Category actions are some important items under the Apps section. These are limited to default Apple apps as these actions can be run on the Home Hub where third-party apps don't exist.

I won’t detail all of these, but some key ones are the Home app where you can find the vital actions Get the status of Home used for querying accessory states, and Control Home which is used to send commands to HomeKit.

Other apps like Calculator are just duplicates of the actions available under the Scripting category. There are a few personal request related items that might be of use in some cases relating to getting and editing Calendar, Reminder, and Contacts info.

Apps with Shortcut actions in the Home app