Alexa home skill node with Lifx Bulbs

Im using the Alexa-smart-home-v3 node. which has a payload HSV value for colors. My lifx node uses CSS for colors. Im using color converter node but it sometimes gives me some names like "lime or winter green" which the lifx-node cant handle. How would I fix this, without manually defining each color from HSV values?

Welcome to the community,

If you are using specific nodes its worth while stating the exact name as often there are several that do the same thing.

I'm guessing you are using
node-red-contrib-color-convert ? But which of the lifx nodes are you using?

is it the "or" that messes up the node? If so you could split the " or "
and then only take the first part.

eg in a function node

//split on the or
msg.payload=msg.payload.split(" or ");
//take first bit only
msg.payload= msg.payload[0];
return msg;

Not sure why color-convert forces to css names and not to hex, but you can use this function to convert it to hex

color-convert should be set to input:HSV, output:RGB, function converts to hex.

[{"id":"536831b5.b250b8","type":"debug","z":"a34cdd6.dcf21a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":300,"wires":[]},{"id":"65795661.c39a5","type":"function","z":"a34cdd6.dcf21a","name":"","func":"function convert(r,g,b) {\n\treturn '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n}\n\ns = msg.payload\nout = convert(s[0],s[1],s[2])\n\nreturn {payload:out};","outputs":1,"noerr":0,"x":625,"y":300,"wires":[["536831b5.b250b8"]]},{"id":"f83dc915.554218","type":"color-convert","z":"a34cdd6.dcf21a","input":"hsv","output":"rgb","outputType":"array","scaleInput":false,"x":475,"y":300,"wires":[["65795661.c39a5"]]}]

sorry when I said "or", I'm just stating the colors that lifx cant recognize

I need the CSS value, but instead of lime, it only accepts green. ex.I say alexa change light to green. I get payload :
saturation: 1

the converter converts that to "lime"

I want to fix that without having to manually define the colors based on hue value.
Coming from Alexa, tasker , lifx plugin and autovoice etc it was pretty straight forward when matching colors.

which lifx node are you using?

The function I gave above converts it into css value.

1 Like


Hex value worked, all along I though I needed a color name

How can I convert this payload to [0,100,100].

what does 0,100,100 represent ?

Array that HSV to RGB can read. I just figured it ou. I used 2 range nodes to change from 0-1 to 0-100 for saturation and brightness. Alexa gives 0,1,1 instead of 0,100,100.

I have it running in terms of color, but now even if I have the brightness at 10% it changes to 100% whenever I change color.

Looking at the alexa node documentation: there is a lot to digest.
Here is a comment from someone who had the same issue. It is 0 > 1 = 0 > 100, 50% = 0.5.

I had it working before where the brightness didn't get changed but the convert function changed that. ill backtrack a see whats different

The point is that you have to divide the values by 100.

1 Like

I found out why the brightness is changing to 100% on color change. the hex value has the brightness set to 100% on every color. I will have convert to a css name and input into msg.payload.color and leave msg.payload.brightness blank