# Set RGB Color using MQTT

**URL:** <https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061>\
**Category:** General\
**Created:** [30 January 2020 22:22 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061 "2020-01-30T22:22:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gavraq](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gavraq](https://discourse.nodered.org/u/gavraq)\
**Post date:** [30 January 2020 22:22 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/1 "2020-01-30T22:22:20Z")

</div>

I am trying to set a color for a RGB light using MQTT. I know that I need to use the cmnd/Topic/Color command but I cant seem to get the message formatting correct. Here is my current flow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82b6368062be096b2b97377301f6c42eb90c0508.png)

You can see that the message comes out as an object whereas I believe it needs to come out in this format: (68, 106, 255) which should then go in to the MQTT in node.

[The Delete a node removes one of the variable from the color picker which has r,g,b and a values whereas I believe the Tasmota is just expecting (r, g, b)]

and here is my rather crude (and unsuccesful) attempt at using a change node to try and format correctly

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2239c8d95e16d9d466aa243a358067998d33ced3.png)  
Can someone help please.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 January 2020 22:54 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/2 "2020-01-30T22:54:49Z")

</div>

the colour picker can send a string instead of an object - that may be easier to reformat as you want.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e36f01341819c22451bcfb16f672f2f06bd0da2.png)

---

<div class="post-metadata">

**Author:** ![gavraq](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gavraq](https://discourse.nodered.org/u/gavraq)\
**Post date:** [31 January 2020 08:06 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/3 "2020-01-31T08:06:28Z")

</div>

yes closer...although the a-value is still there. How can I remove it?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/9833a8df082841f6a3488990b0f1e65bf9c06f78.png)

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [31 January 2020 08:25 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/4 "2020-01-31T08:25:12Z")

</div>

I have set the colorpicker to output format hex8, you can send this direct to tasmota.  
Sample:

```auto
[{"id":"4326fda3.47d38c","type":"ui_colour_picker","z":"8bfffa9d.89ecf8","name":"Lijsterbes Color","label":"","group":"29493404.770ebc","format":"hex8","outformat":"string","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"square":"false","dynOutput":"false","order":3,"width":"2","height":"1","passthru":false,"topic":"/vm/cmnd/RgbSpotTuin1/color","x":880,"y":1160,"wires":[["6dcfca58.95d30c"]]},{"id":"6dcfca58.95d30c","type":"mqtt out","z":"8bfffa9d.89ecf8","name":"Set Kleur Lijsterbes","topic":"","qos":"0","retain":"","broker":"2db287b.addf978","x":1190,"y":1160,"wires":[]},{"id":"29493404.770ebc","type":"ui_group","z":"","name":"Tuin","tab":"209f7863.40989","order":5,"disp":true,"width":"6","collapse":false},{"id":"2db287b.addf978","type":"mqtt-broker","z":"","name":"Mosquitto1","broker":"192.168.1.127","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"/vm/mqtt/birth","birthQos":"0","birthPayload":"birth","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"209f7863.40989","type":"ui_tab","z":"","name":"Verlichting","icon":"lightbulb_outline","order":1}]

```

---

<div class="post-metadata">

**Author:** ![gavraq](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gavraq](https://discourse.nodered.org/u/gavraq)\
**Post date:** [31 January 2020 22:43 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/5 "2020-01-31T22:43:22Z")

</div>

Work perfectly...thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 February 2020 22:43 UTC](https://discourse.nodered.org/t/set-rgb-color-using-mqtt/21061/6 "2020-02-14T22:43:34Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
