Skip to content

Shortcuts Docs

Sean Mooney edited this page Dec 1, 2019 · 5 revisions

With iOS 13 or later, you can take advantage of the power of Siri Shortcuts to carry out Home Assistant tasks with a tap or by using voice commands. With Personal Automations you can combine ....

Explain what Shortcuts is (app by Apple etc),

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")

Home Assistant Shortcut Actions

Home Assistant currently supports five actions for Shortcuts. You can see a listing below, also add a bit more explanation below.

Action Description
Call Service Call a service on the Home Assistant instance.
Fire Event Fire an event to the Home Assistant event bus.
Get Camera Image Get a single still frame from a camera.
Render Template Renders the Home Assistant template.
Send Location Send location to Home Assistant.

Getting Started - Creating Your First Shortcut

  1. Open the Shortcuts app and tap the "My Shortcuts" tab
  2. Tap the blue (+) button in the upper-right corner to create a new shortcut.
  3. Select or search the actions to use. From this screen you can either type "Home Assistant" in the search bar, or select it from Apps > Home Assistant.
  4. Tap the "Call Service" action
  5. You'll see that the "Service" text is colored blue, much like a hyperlink would be on a webpage. This indicates that it's tappable. Tapping on this will bring up all of the services from your Home Assistant instance.
  6. Enter the service data. For this you have two options.
    • JSON {"entity_id": "switch.vizio_tv"}
    • Dictionary
  7. Press the "Play" button in the bottom to test your Shortcut
  8. When you're finished, press the "Next" button in the upper-right corner. You can give your Shortcut a name and customize the icon. Congratulations, you've created your first Shortcut!

Optional Tips (make collapsed list?)

  • By tapping on the "info" button to the right of each action, you can mark that action as a Favorite. This will provide easy access to your most used actions - they'll be just one tap away in the "Favorites" section.
  • You can duplicate an existing Shortcut by long-pressing on it and selecting Duplicate.
  • Run Shortcut action allows you to easily daisy-chain

[DOWNLOAD LINK BUTTON]

Shortcuts Personal Automations

Now that you've learned the basics of the Shortcuts app and successfully created your first Shortcut, let's take things a step further with Personal Automations.

Personal Automations are essentially triggers.

For this example, we'll explain how to trigger a Home Assistant "morning routine" automation after tapping the stop button on your iPhone's wakeup alarm.

  1. Open the Shortcuts app and tap the "Automation" tab
  2. Tap the blue "Create Personal Automation" button
  3. You will be taken to a screen with various triggers, select one to continue. For this tutorial, select the "Alarm" trigger.
  4. On the following screen you'll see the various options for the trigger you selected. The "Alarm" trigger allows it to be run when a specific alarm is snoozed or stopped.

Now when your iPhone alarm clock wakes you up in the morning and you tap the "Stop" button, your Home Assistant morning routine automation will run.

There are many other possibilities. If you have a home gym, you can start a workout on your Apple Watch and have it automatically start a playlist, turn on the fan, etc.

Personal Automation Triggers

Below is a listing of all 14 triggers available from Shortcuts Personal Automations in iOS 13.3.

Trigger Options
Time of Day Sunrise, Sunset, Exact Time of Day, Repeat on Days.
Alarm Alarm snoozed or stopped. Any alarm, wake-up alarm, or specific alarm.
Apple Watch Workout Workout Type: Any workout or specific workout. Workout Starts, Ends, Starts or Ends.
Arrive Arrive at a specified location. At any time or a specified time range.
Leave Leave a specified location. At any time or a specified time range.
Before I Commute To work or back home. At predicted time or certain minutes before (5, 10, 15, 30, 60).
CarPlay When connecting or disconnecting to CarPlay.
AirPlane Mode When AirPlane mode is turned on, off, or toggled.
Wi-Fi When your device joins any Wi-Fi network or a specific Wi-Fi network.
Bluetooth Connects to any Bluetooth device or a specific Bluetooth device.
Do Not Disturb When Do Not Disturb is turned on, off, or toggled.
Low Power Mode When Low Power Mode is turned on, off, or toggled.
NFC When a specific NFC Tag is scanned.
Open App When a specific app is opened.

Note: Apple has erred on the side of caution with this initial release and currently requires manual confirmation for six personal automation triggers - Arrive, Before I Leave, Bluetooth, Leave, Time of Day, and Wi-Fi. When using these triggers, you will receive a notification that you must tap to continue.

The other nine triggers (Airplane Mode, Alarm, Apple Watch Workout, CarPlay, Do Not Disturb, Low Power Mode, NFC, Open App) can be set to run automatically. Simply toggle off the "Ask Before Running" setting.

Note 2: Although Personal Automations get backed up via iCloud, they do not sync across devices. If you create a Personal Automation on your iPhone, it will not be synced to your iPad.

Shortcuts Home Automations

These work for everyone in your home. To use Home Automations, you must own an HomePod, Apple TV, or iPad as a home hub.

Trigger Options
People Arrive Anyone arrives, specific person arrives, first person arrives.
Location (home or specified area).
Time (any time, during the day, at night, specific times).
People Leave ditto above
A Time of Day Occurs Sunrise, sunset, specific time of day, repeat on days.
Conditions: When somebody is home, when I am home, when nobody is home, when I am not home.
An Accessory is Controlled When accessory turns on or off.
Conditions: X
A Sensor Detects Something Detects motion or stops detecting motion.
Conditions: X

Launching Shortcuts

After creating a Shortcut, you have numerous ways to launch them.

  • Shortcuts App - On the "My Shortcuts" tab, simply tap on the shortcut you want to launch. If you have many Shortcuts, you can use the search bar at the top to quickly filter the list.
  • Siri / Voice - You can launch any of your Shortcuts using Siri from any iOS device - iPhone, iPad, HomePod, or Apple Watch. Please be aware that this will override any standard Siri command.
  • Widget - Shortcuts has a widget on the Today View which can be accessed by swiping right from the Home or Lock screen. At the bottom of the widgets screen, press "Edit" and then the green plus button to add the widget to your Today View. Apple Support.
  • Spotlight Search - When on your iOS device Home screen, swipe down from the center of your Home screen to bring up Spotlight search. From here you can type the name of a Shortcut and run it with one tap.
  • Add to Home Screen - When editing any Shortcut, press the (...) button in the top right to see options. You can customize the name or change the icon. These are treated like apps and can be placed into folders.
  • Launch from Home Assistant app push notification - this should be added to Notifications page probably, and then just linked to from here?
  • Add to Lovelace -

When you create a shortcut

After you've created some Shortcuts, you can also launch them from within Home Assistant. Here's an example of how you'd launch a Shortcut using a standard weblink inside a Lovelace Entities card. Simply update the part after ?name= with the name of your shortcut.

- type: weblink
  name: Run Shortcut
  url: "shortcuts://run-shortcut?name=Your Shortcut"
  icon: mdi:layers

If you'd rather have a button instead, you can do this with the custom Button Card.

- type: "custom:button-card"
  name: Shortcut Launcher
  color_type: card
  icon: mdi:rocket
  tap_action:
    action: url
    url: "shortcuts://run-shortcut?name=Your Shortcut"

Note that these Shortcuts URL's will only work while on your iOS device. Clicking on these links from a desktop computer will do nothing.

Using Shortcuts in Notifications

You can send a special push notification to your device, that when tapped, will open the Shortcut of your choosing and run it. Here's an example payload:

---
data:
  shortcut:
    name: XCU
    input: text1
    text: soup1

The input key will be passed into the shortcut as well and accepts a dictionary.

Shortcuts Gallery

Below is a list of pre-made Shortcuts, that should give you a good understanding of how things work.

Additional Help

Get additional help from this guide (link), and the Shortcuts subreddit.