Homey Community Forum

[HOW TO] Trigger Hue Labs formulas in Homey

Hue labs are ‘scenes’ in the Hue app with more advanced features. Only these scenes cannot be controlled by Homey directly via the Hue integration. To control a Hue Labs scene in Homey you need to make a local API connection with your Hue Bridge. For someone with little to no programming knowledge this sounded like a challenge, but was easier than it sounded. So, I thought let’s make a tutorial so you can use this too.

Step 1: find the IP address of your Hue Bridge.

You can find your IP address of your bridge in the Hue App. Go to Settings – Hue Bridges and tap on the ‘i’ icon to see the IP address.

Step 2: make a ‘local user ID’ on your bridge.

This is the most challenging part. For the full story go to

Get Started - Philips Hue Developer Program. Phillips Hue provides a good tutorial. But in short these are the steps.

1: Go to https://YOURIPADDRESS/debug/clip.html (replace YOURIPADDRESS with the IP address you found in ste[p one. So for instance https://192.168.0.0/debug/clip.html

In the CLIP debugger you see URL, Message Body and buttons for GET, PUT, POST and DELETE.

2: To make a local user ID enter the following:

You can replace my_hue_app#iphone peter with anything you want. It does not matter.

3: Before posting this message, go to your Hue Bridge and push the big button to let it know someone wants to connect.

4: Press the POST button in the CLIP Debugger. You should get a message with ‘Succes’ and a username which is a long string of numbers, letters etc. (For instance 1028d66426293e821ecfd9ef1a0731df ). Save this because this is your local user ID.

Step 3: find your lights, sensors etc.

To find all of your devices again go to the CLIP debugger and put the following in the URL part:

/api/YOURLOCALUSERID/resourcelinks (which you replace YOURLOCALUSERID with… you get it, the user ID which you created in step 2.

Then push the GET button.

Then a whole list of all your devices and hue lab scenes will show (see example below)

image

Find the Hue labs formula that you need in Homey. In this case it would be ‘Hue colorloop’.

Step 4: Find the sensor ID

Once you have found your Hue Labs formula, find the sensor ID of the formula. In some cases it could be more than one sensor ID. The sensor ID is the number that is next to “/sensors/”. In this case, the sensor ID is “98”.

Step 5: Create a flow

Now it is time to create a flow which sets the state of the sensor ID to ‘On’ or ‘Off’. You can do this by, in the ‘Then’ section of your flow’ selecting the flowcard ’Make a http web request’ which you can find under the ‘Logic’ section of Homey flows. Then fill in the following:

Method: PUT

URL: http://YOURIPADDRESS/api/YOURLOCALUSERID/sensors/YOURSENSORID/state (in the case of my example that would be http://192.168.0.0/api/1028d66426293e821ecfd9ef1a0731df/sensors/98/state

Headers: leave this blank. This is not necessary

Message body: {“status”: 1}

In the message body you set {“status”: 1} for ON and {“status”: 0} for off. So ideally, you would create two similar flows in which the only difference is the 0 and the 1. In this way you get a flow for turning on ({“status”: 1} ) the Hue Labs formula and turning off the formula ({“status”: 0}.

If your formula has multiple sensor ID’s, put another HTTP web request card in the when part with the corresponding sensor ID.

For the WHEN part, choose the trigger you want. Just a little tip, I would use the ‘This flow has started’ card. This way, you have to do the web request part just for this flow. With other flows you can trigger this flow with the ‘Start a flow’ card in the WHEN part. So for instance, If I have a flow that enables the alarm, in the THEN part of this flow I would start the flow which enables the Hue Lab scene for presence mimicking.

So in this case you can use Hue Labs formulas in your Homey. For me it works great (and fast!). So enabling scenes or things like presence mimicking can be done in Homey.

Let me know if there are any questions and I am curious which Hue Labs formula’s you use in your Homey Flows.

EDIT:
Oh and bonus tip: it is to be advised to set the hue bridge to a static IP address. Or else the flow will lose the IP address since it does not adjust it to the new IP address when set to dynamic. So if you do not do this there comes a time that your flows do not trigger the Hue lab scene anymore since the IP address of the bridge has changed.

I have set a static IP address for my bridges (yes bridges…) on my router. But you can do this in the hue app as well. Go to your bridge in the hue app, tap the ‘i’ icon and go to Network settings (Netwerkinstellingen). You can turn of DHCP and set a static IP. But be carefull. If this goes sideways you have to reset the bridge to get access. So I would recommend doing this on your router.

5 Likes

Nice, it works perfect
Thanks m8

Hi Kevin, Do you know what i am doing wrong if the response I am getting in the Clip API Debugger is “error type 2” and “body contains invalid json”
Any ideas?

That depends. If it says that the JSON is incorrect you have to look at the exact way you entered things in the ‘body’ field. Did you use the quotes? Maybe you could send or post a screenshot so we can take a look at it.

And welcome to the community :wink:

Thnx for the welcome! Ok I think I typed it all as it should but for some reason it does not give me the user… I tried with different ipad names etc.

Sorry, I’m not an api expert unfortunately. I got it working following these steps: Get Started - Philips Hue Developer Program Maybe this will help you further?

Thanks Kevin. No worries I have approached a local IT tech person I know. He is currently checking for me to see if he can get a response from the bridge. If it works I will post the result here so that other people can use it when running into the same issues.

Hi Kevin, Just to let you know I have cracked it and it works! The trick was in the fact that you have to copy and paste the exact text. Apparently the quotes which I used were not the right ones.
Now it is all done and installed and running. Excellent job! Thanks a lot for your help.

Great!.

Oh and bonus tip: it is to be advised to set the hue bridge to a static IP address. Or else the flow will lose the IP address since it does not adjust it to the new IP address when set to dynamic. So if you do not do this there comes a time that your flows do not trigger the Hue lab scene anymore since the IP address of the bridge has changed.

I have set a static IP address for my bridges (yes bridges…) on my router. But you can do this in the hue app as well. Go to your bridge in the hue app, tap the ‘i’ icon and go to Network settings (Netwerkinstellingen). You can turn of DHCP and set a static IP. But be carefull. If this goes sideways you have to reset the bridge to get access. So I would recommend doing this on your router.

I have added this extra tip to the first post :wink:

Thanks for the free tip. I will for sure sort this out! Will confirm how it went once done.