Controlling Philips Hue with Shortcuts

It turned into a real mess so I decided to modulate it. I apologize for all the Shortcuts you’ll need to download, but I promise the experience is worth it.

The “modules” are dependent upon each other. I’ll try to explain it the best I can.

Hue GetBridgeIP()
This either takes the bridge’s IP address you’ve provided, or discovers it on its own. It’s more efficient if you supply the IP in the Text field, but it will work without it too._

Hue GetConfig()
This calls GetBridgeIP() and adds your Phillips Hue API key to a centralized config dictionary that gets called by later modules. I haven’t yet been able to work on getting the API key automatically, but I plan to soon. For now, you can get yours by going to their dev site.

Hue GetLights()
This gets all your lights into a custom dictionary object. I am doing this mostly to flatten the light object returned by the API and only grab what I want/need at this time.

Hue GetGroups()
Same as above, but with your groups (rooms).

Hue ChooseLight()
This calls the GetLights() module and presents you with a list of your lights for selection and outputs a dictionary object from that.

Hue ChooseGroup()
Same as above, but with your groups (rooms).

Hue ChooseTransition
This is how I imagined I wanted things to work for me. It presents you a list of pre-defined durations with extra options for manual input. It takes your selection and does some calculations on it in order to feed it to the API later in the specific millisecond value.

Hue ChooseBrightness()
Presents you with a list of pre-defined percentages for brightness for the dictionary object (light or group) passed into the Shortcut and returns the brightness level in the API’s format.

Hue SetBrightness()
This sets the brightness of the light or group immediately from the custom dictionary light/group object passed into the Shortcut.

Hue Toggle()
This guy presents you with a list of options for toggling that light or group. Right now it has 5 options:

  • Quick On turns the selected light or group on and to 100%
  • Turn On turns the selected light or group on without setting the brightness manually
  • Turn Off turns the selected light or group off
  • Fade In slowly turns the selected light or group on over the selected duration
  • Fade Out sets a starting brightness and slowly turns off the selected light or group over the selected duration

For example, I strung together ChooseLight() and Toggle()

I must say, the experience of using these has been completely gratifying. I love how this turned out and I hope you do too! I will continue to add more modules to this and hopefully include colors and such.


These look great! Makes me want to buy-in to the Hue economy just to use all of these shortcuts. :grin:

Haha! You really should. The lights are great! As for the shortcuts above, I really cannot stress enough how much easier it is to use those than the actual app itself (plus it’s faster :wink: ).

Do you not use the Hue Widget? I’ve got loads of presets all available at the click of the button (just above my Shortcut widget) What are the added advantages of the above?

Is it due to multiple rooms/groups? I only have my main lounge with Hue lights at the moment…

I do have the Hue widget and use it sometimes, but for some reason I cannot train my brain to swipe over to the widget and use it. I also like a clean widget screen. I try to keep only 3-4 in there so I don’t have to scroll and it’s mostly taken up by my calendar at the moment.

Plus, with the above Shortcuts I can create any combination of groups I would like whereas the Hue app only allows a light to be in one group at a time.

Finally, the biggest driving factor for this was to tell a light or group to fade starting “now” (on demand). The Hue app has timers, and nighttime/morning routines, but none of them can be triggered on demand. For my kids, I always had to go into the app, tap routines, tap go to sleep, find the one I want, tap it, edit the time to fit the current time. The Shortcuts above, you can tap a light/group and choose a fade duration and you’re done.


1 Like

Very cool, I’m convinced!

1 Like

Nice! I have to look into that some time. For now I found a way that sort of works for me at the moment. It’s very crude and cloncky, but it sort of works.

1 Like

Sweet man! Hope you do try it some day soon. :grinning:

i cant find the api …

I have improved these shortcuts greatly since posted. I’ll try to re-post with my updates.

Hey @fischgeek
Could you share your new shortcuts ?:slight_smile:.

I just tried the original ones and I can select my lamps so in general it seems to work (the connection with the bridge with my api credentials) but unfortunately the lights don’t react.
Is it maybe because of ios13 or should it still work?

This for instance is the error I get from the shortcuts app if I try to set a brightness with “Hue SetBrightness()”:

{"error":{"type":4,"address":"zSVm0FvYBbD-nJI-Tp1MxNx1PVc8DGRdADlUBihl\/lights\/\/state","description":"method, PUT, not available for resource, zSVm0FvYBbD-nJI-Tp1MxNx1PVc8DGRdADlUBihl\/lights\/\/state"}}

Would be fantastic if you could help me with it as I really like your idea of the shortcuts :smiley:


Hey @Thorsten_K, I’ll take a look at it, but it seems to be working for me still on iOS 13.

@Thorsten_K, add a Quick Look to the action just before Get contents of URL in the Hue SetBrightness() shortcut and see what the full URL ends up being.

I tried to follow these steps to get my API:
However, I never get a command response… Independent of the input and browser. Did somebody experience the same behavior?

If you’re talking about the CLIP API debugger theres a bug with it

For what it’s worth, I found a workaround on Reddit: “Workaround in Firefox is to go to about:config and change security.csp.enable to false”

Hey, i know its late but i would love to use these shortcuts.

How i can implement as a shortcut.

  • choose Kitchenlamp
  • turn on with transition 300ms

Wow at last somebody who knows how to program shortcuts properly.

I’ve been trying to use shortcuts within homekit and hue environment to automate sensors. Using native HomeKit time intervals and then shortcut if statements and get weather (sunset sunrise) or current date details for day of week.

Got stuck on the fact I can get the current settings of a lamp (brightness, hue, saturation) but can not set them programmatically in the same way.

Looking at these shortcuts they bypass the HomeKit app and use URL’s on the hub to get and set what I need.

Do I need to enable anything specific on my HUE hub for these to work or will it just trust shortcuts?

You need to get the API key for your Hue hub. It is mentioned in the first post and is what means that only authorised devices/code can interact with the hub.