# Connect Hue with RGBW

**URL:** <https://discourse.nodered.org/t/connect-hue-with-rgbw/14925>\
**Category:** General\
**Created:** [30 August 2019 05:35 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925 "2019-08-30T05:35:24Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![wburst](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@wburst](https://discourse.nodered.org/u/wburst)\
**Post date:** [30 August 2019 05:35 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/1 "2019-08-30T05:35:24Z")

</div>

Hi Guys

I have a little Problem with Hue

I have KNX and want to control Hue

From KNX i just have seperate Objects for R,G,B,W and want to connect this to the Hue ligth.  
But how can i do this. theoretical i ned 4 Sliders for R,G,B,W  
I can choose HSL oder HSB

![HueKNX](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/63bc87072f93ae916ec593c75fd6438b78914fce.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:** [30 August 2019 06:49 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/2 "2019-08-30T06:49:12Z")

</div>

There is a node available 'node-red-contrib-color-convert' which can convert RGB to HSL/HSV. For the `W` you may need to do it seperately in Kelvin.

---

<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:** [30 August 2019 07:07 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/3 "2019-08-30T07:07:12Z")

</div>

Can you give us an example of the objects?

You might have to store the values using context variables. There’s a page in the docs called “working with context”

---

<div class="post-metadata">

**Author:** ![wburst](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@wburst](https://discourse.nodered.org/u/wburst)\
**Post date:** [30 August 2019 07:22 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/4 "2019-08-30T07:22:13Z")

</div>

Can you give me an example of the color convert ?

---

<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:** [30 August 2019 07:33 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/5 "2019-08-30T07:33:33Z")

</div>

As the documentation describes:

> For the first 3 input modes the node will attempt to determine the input format of msg.payload from the 3 following:
> 
> - a 3 segment array with values between 0-255 for RGB.
> - a 3 segment array for HSL and HSV with Hue is between 0-360 and Saturation, Level, values 0-100.
> - a object with keys red,green,blue with values between 0-255.
> - a object with keys hue,saturation,lightness or value,brightness with values between 0-360 for hue and 0-100 for the others.

Do you have RGBW payload available ? If yes, what does it look like ?

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [30 August 2019 08:42 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/6 "2019-08-30T08:42:03Z")

</div>

One option could be to use a function-node. In my plugin `homebridge-mqtt` you'll find 2 convert-functions ([https://github.com/cflurin/homebridge-mqtt/blob/master/lib/utils.js](https://github.com/cflurin/homebridge-mqtt/blob/master/lib/utils.js))

```auto
Utils.rgb2hsv = function(r, g, b) {
...

```

and

```auto
Utils.hsv2rgb = function (h, s, v) {
...

```

---

<div class="post-metadata">

**Author:** ![wburst](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@wburst](https://discourse.nodered.org/u/wburst)\
**Post date:** [30 August 2019 09:56 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/7 "2019-08-30T09:56:46Z")

</div>

Maybe is now Clearer what i mean.  
Maybe someone has an Expample.  
Im verry new with node Red

 ![HueKNX1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0dbc68b6a82bf851369d0621f28e1cef6ecb93ad.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:** [30 August 2019 10:18 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/8 "2019-08-30T10:18:11Z")

</div>

3 separate payloads can be combined with the join node.

What does the ouput of the knx node produce? (Connect a debug node to it)

---

<div class="post-metadata">

**Author:** ![wburst](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@wburst](https://discourse.nodered.org/u/wburst)\
**Post date:** [30 August 2019 12:10 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/9 "2019-08-30T12:10:21Z")

</div>

> [@bakman2](#):
>
> 3 separate payloads can be combined with the join node

Thats why i said im newbie how must i do that ?

---

<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:** [30 August 2019 12:29 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/10 "2019-08-30T12:29:59Z")

</div>

What does the ouput of the knx node produce? (Connect a debug node to it)

---

<div class="post-metadata">

**Author:** ![cflurin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cflurin/32/29_2.png) [@cflurin](https://discourse.nodered.org/u/cflurin)\
**Post date:** [30 August 2019 12:45 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/11 "2019-08-30T12:45:40Z")

</div>

Assuming you are using the `heumagic` node:

1. You need to send an object like this (see doc):

```auto
{rgb:[r,g,b]}

```

1. First build an array with the join node and then an object with the template node.

Import and try this flow:

```auto
[{"id":"b3155e60.37d73","type":"join","z":"7c6a9ec3.f1512","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":390,"y":1260,"wires":[["207e45ca.32f6ea"]]},{"id":"c188ba2d.8da4f8","type":"inject","z":"7c6a9ec3.f1512","name":"","topic":"red","payload":"200","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":1220,"wires":[["b3155e60.37d73"]]},{"id":"99e929d7.500088","type":"inject","z":"7c6a9ec3.f1512","name":"","topic":"green","payload":"180","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1260,"wires":[["b3155e60.37d73"]]},{"id":"906a8390.860e7","type":"inject","z":"7c6a9ec3.f1512","name":"","topic":"blue","payload":"210","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1300,"wires":[["b3155e60.37d73"]]},{"id":"54bd1ebb.28a31","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":1260,"wires":[]},{"id":"207e45ca.32f6ea","type":"template","z":"7c6a9ec3.f1512","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{rgb:[{{payload}}]}","output":"str","x":520,"y":1260,"wires":[["54bd1ebb.28a31"]]}]

```

---

<div class="post-metadata">

**Author:** ![Hubertus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hubertus/32/10077_2.png) [@Hubertus](https://discourse.nodered.org/u/Hubertus)\
**Post date:** [7 April 2022 14:30 UTC](https://discourse.nodered.org/t/connect-hue-with-rgbw/14925/12 "2022-04-07T14:30:36Z")

</div>

Hallo, danke für den Hinweis auf die Funktionen. Mir ist nicht klar wie die Eingangsparameter sein sollen. Ich habe h = 60, s = 75 und v = 185 (gesendet von Zigbee2MQTT) - wenn ich die Funktion damit aufruf kommen unsinnige Werte dabei heraus.

Danke für ein Lichtblick 😉
