[Tutorial] How to create your own iOS shortcuts using the Maker API

Hey everybody!

With the release of the Maker API and the introduction of the Shortcuts app on iOS, I've been itching to get something setup to make them interface. I've seen a few people ask about it, but I haven't really seen a tutorial yet so this is an attempt to bridge that gap. It's not the most comprehensive, but hopefully it's enough to get your feet wet and show you there isn't anything to worry about!

Admittedly, I got something rudimentary setup fairly quickly so I'll show that method first, and then I'll show a slightly more complicated example.

One of the most popular things you could do with the Shortcuts app is to trigger some sort of automation within Hubitat. The Maker API makes that pretty simple, especially when you factor in Rule Machine or other automation triggering apps.

For my simple example, I'll be showing how to push a button. This button push example can be extrapolated to a bazillion other actions in Hubitat; basically anything that is fire and forget. If you setup your own automation to "Wash the dog and turn on the TV to cartoon network" when you press a button, this workflow will work for you.

Step 1: Wire your button to an automation.
This isn't necessary if your "button" is a simple light you would like to turn on or off (not both, just one or the other). Basically, get things working to where if you press the button, your automation runs. This can be a virtual button or a real button. Just make sure when you click the button, something happens.

Step 2: Make your button available to the Maker API.
I won't go into the details here. It's fairly straightforward.

Step 3: Create a new shortcut on in the iOS app
Here's where the meat and potatoes is.

For those of you who are more tech literate, this is the gist of it.

First we add a URL component to Shortcuts, and then we add a Network component and tell it to get the contents of the URL. The URL we are retrieving is the Make API URL to trigger our button press.

An example URL from a virtual button in my setup would be http://hubitat-ip/apps/api/229/devices/386/push/1?access_token=FAKETOKENHERE

This is accessing the Maker API (app 229 in my setup) and then pushing button #1 in my virtual button device (device #386).

If I want to push button 2 of my virtual button, I can change the 1 at then end to a 2. If I want to trigger the double tap action, I can change push to doubleTap or any of the other commands supported by the device. You can view the devices capabilities by examining the JSON returned by the Maker API at http://hubitat-ip/apps/api/229/devices/386?access_token=FAKETOKENHERE

Download a browser extension on your desktop computer like JSON View for Chrome to see the output formatted so you can read it more easily. There are similar extensions available for all major browsers.

That's pretty much it. Simple duplicate the Shortcut as many times as you want and change the URL to any valid command within the Maker API for any valid devices. You can then wire up Siri to trigger those commands Correction: it appears that with iOS 13, Siri is automatically wired up to trigger shortcuts when you say the name of the shortcut. This was/is configurable in iOS 12. I'm not sure if it can be overwritten in iOS 13. I don't use voice commands at all in my setup but I did test it and it seemed to work. If you want a more fluid speech API, you may need to duplicate a shortcut a few times and give it varying names.

I have used these pretty successfully for about 6 months now to do really simple things, mainly to trigger turning all the lights off in my house when I'm laying in bed. I'm usually playing on my phone anyway, so clicking on the widget is easy.

More complicated shortcut.

Now the limits here really are endless so I won't get into too deep, but for this example, I'm going to show how to Toggle a light from on to off depending on it's current state. For me, this meant reducing 2 shortcuts (1 for on, 1 for off) to a single shortcut that will read what the current state is and flip it. I use this for my bedroom lamp which has a smart bulb in it. Adapt this however you want. It will take some trial and error!

First, download the Pretty Print Dictionary shortcut to help you test. You can read the linked Reddit thread to learn more about it.

Because I'm lazy I'm not going to paste in 3 or 4 screenshots here. It's not going to be the exact same with your devices anyway.

First we start out the same. Get the URL for the device you want to check the status of. Something like .../devices/229 then get the contents. Next, we're going to add a scripting action called Get Dictionary Value. You're going to make sure the first parameter is set to Value and then the next parameter will be attributes. This will return an array/list of attributes from the device. If you look at the Maker API response for the device, you'll see this list of attributes.

The next scripting action is a Get Item from List. Now I am telling the action to grab the item at index 10 for my specific device. You may need to use the Pretty Print Dictionary action to see what the index of your specific attribute that you're looking for is. When the Shortcuts app processes the attributes list, it will sort them, so you can't rely on the order they are returned by the Maker API natively. In my example, this is a connected Hue bulb that has a lot of different attributes. I'm trying to read from this one:


This switch attribute shows the on/off status of the bulb.

Within my shortcut, this is item at index 10.

Next we have another Get Dictionary Value action. This one is reading the value of the currentValue key from the object returned by the Maker API.

Finally we're going to run an If scripting action to branch depending on if our light is on or off.

If the light is on, we're going to trigger the URL for the device to turn it off and vice-versa. This is the exact same procedure as the "dumb" shortcut above. Just get the contents of the appropriate URL again.

Within the if/otherwise branches, you can set other variables or show notification popups, but that's all out of the purview of this tutorial.

The hardest part of this is navigating the API response from the Maker API within the Shortcuts app. I'm a programmer by trade and this was not the most intuitive for me. It took a solid 2 hours I think from start to finish the get the toggle working. Lots of research and trial and error.

The most helpful thing you can do is download the browser extension I recommended earlier and then go look at the Maker API response pages for the devices you want to control. This should give you an idea of what is possible with simple triggers. Also, if you have a Mac, you can tweak the URLs to be perfect on your desktop and then copy/paste those to your iPhone as long as handoff is enabled. This makes it easy to tweak values with a real keyboard and then just visit the URL in the browser and that will trigger things. Or get the URLs perfect and email them to yourself if you don't have a Mac. You're all very smart people :wink:

Here's a little video of my humble toggle. You can see I've got some extra stuff in there, but that's not necessary for it to work.

Hopefully this exercise will get you more comfortable messing with the Shortcuts app. It's fairly difficult to screw up anything too hard on the Hubitat side!

My recommendation will always be to do this in front of your computer with the Hubitat dashboard up and ready to revert any changes you are making, especially if you want to get into arming security devices or similarly "high risk" devices.

Happy to attempt to answer any questions but I'll likely be offline the rest of tonight (USA central time).

Good luck!


Awesome! The onyl thing is I get this error:

app:16372019-12-01 11:30:32.310 am errorjava.lang.NullPointerException: Cannot invoke method getSupportedCommands() on null object on line 394 (sendDeviceCommandSecondary)

Why not just use a shortcut to trigger a rule with an endpoint? The rule could do the toggle.


Figured it out! Was totally on my end, wrong device ID.
This is pretty damn sweet, I can now control things with my phone as well as Alexa.

i have my MYQ Garage door setup so that when iu am in my car, using Apple Carplay, i can hit my Siri button on the steering wheel and say Open garage Door, now i can add items from my hub to do events with my lights, etc.

To be honest, I haven’t kept up with Rule Machine since v4 came out and I haven’t been able to find a good tutorial explaining things.

Right now I have a half dozen half assed rules that don’t seem to work how I want and I’m not sure why.

Got a good tutorial or documentation page explaining things that I might have missed? It would be nice to not have to try and parse all that stuff on the device and instead just hit another endpoint!

Endpoints are super easy in RM. You simply create a Trigger Event for either Local or Cloud Endpoint. It gives you the link that you should copy. That is the link that will go in Shortcuts. Then, in the actions section, do whatever actions you want the shortcut to perform.

Maker API is really not the right tool to use with Shortcuts, as it puts all of the labor in the Shortcut. That labor is more easily done in the hub with RM.

See Rule Machine - Hubitat Documentation and there are two new tutorial videos about it here and here


Any chance for a working example? When i try to create a rule I get errors from the URL generator.
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
Don't get very far so no screen shots to link.
End goal is to have Siri turn on a virtual switch.
Thanks for any help.
Sorry. This is for bravenel

1 Like

Working example of what? A rule that is run by a Shortcut?

In the screenshot of my just prior post above, you right click on the "Cloud End Point URL" and copy the link. That is then used as the URL in the Shortcut.


First of all, I am mainly an Android user so don't really understand IOS. But am in the process of setting up a friend on HE and he use Iphones. It looked like the shortcuts would be very handy for him.

My wife has an Ipad, so I thought I would experiment on that. I was able to create a shortcut, no problem. But ran into a snag when trying to add to home screen. I hit the box/uparrow thingy and it gave me a menu. Selected add to home screen. That brought up a popup to select an icon, color, etc. I hit done and that just brought up a set of instructions telling me how to do what I just did. Can't seem to get to the point of actually adding to the home screen.

Any suggestions?

That sounds like it's something to do with your device. Have you tried restarting the iPad and trying again? It might have just been bugged for some reason.

I figured out my issue with getting it on the home screen.

I can configure a shortcut to do what I want. But when I click the shortcut on the home screen it opens up another big page with a lot of info on it. How can I just hit the shortcut button and it does its thing but doesn't open up anything?

What is the final step of your shortcut? Maybe you should add a notification at the end or something and see if that stops it from opening the app.

I use all of mine in the widgets drawer on the far left, and I'm too lazy to test a home screen implementation at the moment :slight_smile:

No problem. It opens up and displays the return. I'm gonna keep playing with it. Takes time as it is my wifes iPad, and have to get her to let go. I'll let you know what I come up with. Thanks for help.

What did you do to fix that error? I am running into the same issue.

"getSupportedCommands() on null object on line 394 (sendDeviceCommandSecondary)"