Switch scene with white Led setting

Hi there,
I currently have a scene that changes the current state of two Led bulbs from on to off or off to on using the following code:
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “ToggleState”, {}, 51)
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “ToggleState”, {}, 3)
return true

If possible I would like to add into this scene to turn the colour to bright white and I believe below is the correct colour setting:
0=252,1=255,2=108,3=224,4=227
Might anyone please be able to assist with the code combination to achieve this correctly.
Thank you for taking time to read this!

try with this code:

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorRGB', {newColorRGBTarget = '0=252,1=255,2=108,3=224,4=227'}, devid)

where devid is your device id.

The following fails
luup.call_action(“urn:micasaverde-com:serviceId:Color1”, “SetColorRGB”, {newColorRGBTarget = “0=252,1=255,2=108,3=224,4=227”}, 51)

luup.call_action(“urn:micasaverde-com:serviceId:Color1”, “SetColorRGB”, {newColorRGBTarget = “0=252,1=255,2=108,3=224,4=227”}, 3)

luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “ToggleState”, {}, 51)

luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “ToggleState”, {}, 3)

make sure your quotes are ok, or just replace with single one (’). It seems the forum is formatting them in a weird way.

is the below better? still fails tho

luup.call_action(“urn:micasaverde-com:serviceId:Color1“, “SetColorRGB“, {newColorRGBTarget = “0=252,1=255,2=108,3=224,4=227“}, 51)
luup.call_action(“urn:micasaverde-com:serviceId:Color1“, “SetColorRGB“, {newColorRGBTarget = “0=252,1=255,2=108,3=224,4=227“}, 3)
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1“, “ToggleState“, {}, 51)
luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1“, “ToggleState“, {}, 3)

try this:

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorRGB', {newColorRGBTarget = '0=252,1=255,2=108,3=224,4=227'}, 51)
luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorRGB', {newColorRGBTarget = '0=252,1=255,2=108,3=224,4=227'}, 3)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 51)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 3)

Can you also describe what “fails” means? Does it mean the code issues an error? Does it mean the code doesn’t set the color correctly? …?

Thanks, this works except I have the wrong colour setting, I am attempting to have the lights change from a dim blue back to bright white. The attached screenshot shows the light variables when the light is bright white. Perhaps some slight modifications to the script are required to get to this bright white variable?

The code that was failing produced the following results when running under apps develop apps test luup

OK. I just noticed that even in @therealdb 's code snippets, the single quotes are broken. This isn’t his or the forum’s fault–editors, especially on Apple, do this, and one has to take great care that they are using a pure text editor.

So his code should look like this:

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorRGB', {newColorRGBTarget = '0=252,1=255,2=108,3=224,4=227'}, 51)
luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorRGB', {newColorRGBTarget = '0=252,1=255,2=108,3=224,4=227'}, 3)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 51)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 3)

Notice the difference in highlight colors between my version above and how the forum presents his earlier version. That’s an extraordinarily subtle hint that something wasn’t healthy.

But I think there’s another issue at play here. In my work on the Yeelight plugin, which involved a lot of research into these actions, parameters and variables because they are so poorly documented, I found no analogue for the syntax you are trying to use for newColorRGBTarget. As far as I know, that should be a simple comma-separated triplet of red/green/blue byte values (such as newColorRGBTarget="255,128,64"). Luup uses the format you show in your action to store the current target value, but it does not receive it that way, as far as I know. If you look at how the Vera UI’s own color wheel widget uses this same action to set colors on a lamp, it always uses the r,g,b triplet format.

So I would start by simplifying the newColorRGBTarget value to just r,g,b (255,255,255 would be all on bright white, 255,255,0 would be yellow, etc.).

Since you’re looking for white, another way to go would be to use the SetColorTemp action to set the lamp white at a specific color temperature. It takes one parameter newColorTempTarget with a value Wn or Dn where W is for the warm color range (2000-5500K) and D is for the daylight color range (5500-9000) and n is a number 0-255 for the value in that range (e.g. W51 is about 2700K, W255 is 5500, D0 is also 5500, and D36 is about 6000K).

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorTemp', {newColorTempTarget = 'W51'}, 51)

Thanks Rigpapa for the detail and options.
I ended up going with D36

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorTemp', {newColorTempTarget = 'D36'}, 51)
luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorTemp', {newColorTempTarget = 'D36'}, 3)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 51)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 3)
return true
1 Like

I can not edit previous post (i assume someone has fixed coding format again and locked it) but i wanted to say a big thank you to therealdb also!
So Thanks gents!

Edit:
I ended up testing more and decided on the following White is best for my Aeotec Smart bulbs:

luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorTemp', {newColorTempTarget = 'W199'}, 51)
luup.call_action('urn:micasaverde-com:serviceId:Color1', 'SetColorTemp', {newColorTempTarget = 'W199'}, 3)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 51)
luup.call_action('urn:micasaverde-com:serviceId:HaDevice1', 'ToggleState', {}, 3)
return true

I hope this formatting is correct as i simply copied and pasted from a working scene in vera

W199 is fine. When posting code, please put three “backticks” (same key as tilde on US keyboards) like this ``` on a line by itself both before and after the code. That will ensure that your code block is properly formatted as code and nothing gets changed by the forum display–a benefit to future users who may grab your snippet.

© 2019 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy