# Alexa home skill node with Lifx Bulbs

**URL:** <https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076>\
**Category:** General\
**Created:** [9 July 2019 13:39 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076 "2019-07-09T13:39:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 13:39 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/1 "2019-07-09T13:39:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 July 2019 13:57 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/2 "2019-07-09T13:57:22Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 13:58 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/3 "2019-07-09T13:58:57Z")

</div>

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.

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 14:17 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/4 "2019-07-09T14:17:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 14:24 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/5 "2019-07-09T14:24:46Z")

</div>

I need the CSS value, but instead of lime, it only accepts green. ex.I say alexa change light to green. I get payload :  
hue:120  
saturation: 1  
brightness: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.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 July 2019 14:29 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/6 "2019-07-09T14:29:46Z")

</div>

which lifx node are you using?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 14:35 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/7 "2019-07-09T14:35:40Z")

</div>

The function I gave above converts it into css value.

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 15:05 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/8 "2019-07-09T15:05:37Z")

</div>

Node-red-contrib-lifx-api

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 15:16 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/9 "2019-07-09T15:16:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 15:29 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/10 "2019-07-09T15:29:05Z")

</div>

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

 ![15626861026454876459436659113376](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/70a151100af86677b6c8bfc4a106a9652b306670.jpeg)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 15:35 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/11 "2019-07-09T15:35:43Z")

</div>

what does 0,100,100 represent ?

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 15:48 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/12 "2019-07-09T15:48:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 16:05 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/13 "2019-07-09T16:05:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 16:17 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/14 "2019-07-09T16:17:20Z")

</div>

Looking at the alexa node documentation: [there is a lot](https://github.com/coldfire84/node-red-alexa-home-skill-v3-web/wiki) to digest.  
Here is a [comment from someone](https://github.com/coldfire84/node-red-alexa-home-skill-v3-web/issues/15) who had the same issue. It is 0 \> 1 = 0 \> 100, 50% = 0.5.

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 16:27 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/15 "2019-07-09T16:27:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [9 July 2019 16:34 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/16 "2019-07-09T16:34:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codycato1882](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@codycato1882](https://discourse.nodered.org/u/codycato1882)\
**Post date:** [9 July 2019 16:42 UTC](https://discourse.nodered.org/t/alexa-home-skill-node-with-lifx-bulbs/13076/17 "2019-07-09T16:42:58Z")

</div>

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
