[Solved] How to activate HUE dynamic scenes?

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

[Solved] How to activate HUE dynamic scenes?

Post by Sarcas »

Does anyone know how to activate the new HUE dynamic scenes? The scene-devices created by the HUE plugin just activate the static version.

Thx

Edit:
I figured it out. Will post if anyone is interested.
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
gomario
Posts: 19
Joined: Wednesday 04 November 2015 6:05
Target OS: Windows
Domoticz version:
Contact:

Re: [Solved] How to activate HUE dynamic scenes?

Post by gomario »

Well, you might as well share with the class:) Thanks
lholwerda
Posts: 3
Joined: Saturday 28 November 2020 1:33
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: [Solved] How to activate HUE dynamic scenes?

Post by lholwerda »

can you please let us know how you splved this?
Sarcas
Posts: 86
Joined: Wednesday 11 October 2017 8:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1ß
Location: Friesland
Contact:

Re: [Solved] How to activate HUE dynamic scenes?

Post by Sarcas »

I was hoping to present a nice clean script with fabulous options, but it takes me much longer than expected and there is so much to do and the weather is nice and ...

Anyway, the core is this (this is just a test script, you will have to change it to make it work for you):

Code: Select all

return {
	on = {
		devices = {
			2418 -- virtual test button
		},
		httpResponses = {
		    'HUE_DYNAMIC_SCENES'
	    }
	},

	logging = {
        level = domoticz.LOG_DEBUG,
        marker = "HUE_DYNAMIC_SCENES"
    },

	execute = function(domoticz, triggerItem)
	    local myHueBridgeIp     = domoticz.helpers.myHueBridgeIp
	    local myHueApiKey       = domoticz.helpers.myHueApiKey
	    local myHueTestscene    = 'cc28d5cb-e381-4336-ae1d-6fba567c955b'
	    
    	if (triggerItem.isDevice) then
            domoticz.log('Script started, trigger = '.. triggerItem.name , domoticz.LOG_DEBUG )
            
            domoticz.openURL({
                url = 'https://' .. myHueBridgeIp .. '/clip/v2/resource/scene/' .. myHueTestscene,
                method = 'PUT',
                callback = 'HUE_DYNAMIC_SCENES',
                headers = {
                    ['hue-application-key'] = myHueApiKey
                },
                postData = {
                    recall = {
                        ['action'] = 'dynamic_palette'
                    }
                }
            })
        
        elseif (triggerItem.isHTTPResponse) then
            domoticz.log('Script started, trigger = HTTPResponse' , domoticz.LOG_DEBUG )
            
            local response = triggerItem
            if ( response.ok and response.isJSON ) then
                domoticz.log('Command OK', domoticz.LOG_DEBUG )
            else
                domoticz.log('Command not ok', domoticz.LOG_DEBUG )
                response.dump()
            end
        end
    end
}
It uses the new HUE API Version 2, which is really different from the previous version. It took some experimenting.
myHueBridgeIp obviously is the ip address of your HUE bridge.
myHueApiKey is the api-key you get from the bridge.
myHueTestscene is the API v2 ID of the HUE scene you want to activate. You can find the scenes with the API Clip debugger:

In a browser goto https://yourbridgeip/debug/clip.html
Enter in the URL field : https://yourbridgeip/clip/v2/resource/scene
In Headers on the left side "hue-application-key" , without the "".
In the field next to it enter your api key
Then click GET
The Command response field spits out a lot of info. You want to look for parts that look like this:

Code: Select all

			"id": "cc28d5cb-e381-4336-ae1d-6fba567c955b",
			"id_v1": "/scenes/BghBTO8dK9lrmtA",
			"metadata": {
				"image": {
					"rid": "d271d202-6856-4633-95ae-953ba73aee64",
					"rtype": "public_image"
				},
				"name": "Honolulu"
			},
So, the id for scene Honolulu is cc28d5cb-e381-4336-ae1d-6fba567c955b

Good luck :)
--

Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest