Color Picker Support for RGBW

I have a MerkuryA21 RGBW bulb ( with tuya-convert flashed sonoff / tasmota firmware) that accepts colors in the form of 255,255,255,255. I was super excited to see the color picker that's included in the default NR palette but I can't get it to work for me because all the options are not RGBW. It does change the lightbulb color but not to the right color, if you catch my drift.

I looked at flows and did some pretty decent googling and I am not a programmer. I do know that I can use sliders for each of the 0,0,0,0 and then look at the bulb and say... "that's fuscia" and then hard code fuscia into a flow. I will if I have to but I would like more flexibility and ease of use.

Any chance anyone can point me in the right direction on how best to use node red nodes to be able to use the color picker because I love the UI for the dashboard

I am ok at modifying other's work, but all the convert from RGB to RGBW on the internet appears to be above my paygrade... hence NR nodes.

Thanks for any points in the right direction!

Did you have a look at the node-red library for contrib-nodes? Searching the string RGBW returns two contrib-nodes and a flow.

Yeah one is for daylight control (cold white to warm white) the other seems to be chip specific. But I may be missing a whole section of search. I searched flows on the website and I searched in node red palette mgr

I didn’t see anything more than what you mentioned. But let me dig deeper in case I missed something

EDIT: Yep. those three resources don't seem to offer any insight into my need to convert rgb to rgbw. I also scoured google, stackoverflow, youtube, the tasmota-sonoff github, and I came up empty handed.

I'm going to go the plug and chug route of 4 sliders and figure out what number combos match what colors unless someone can help with a different way.

It would be great if the color picker natively supported RGBW.

Your basically entering an esoteric part of the colour world which is why not much info on it.

RGB gives you 64 million colours to play with

Introducing W just means that having picked an RGB colour - adding in some W just desaturates it (makes it lighter)

What colour you get from any combination of RGB is dependant on the actual individual R,G and B LEDs inside the bulb and won't be very accurate compared to a colour picker chart.

Adding in W just makes the whole process more inaccurate

2 Likes

I suspect you are right. I suspect that in the hacked but not opened RGBW bulb there are white leds and r g b led's and I need to address the white completely separately from the RGB..

The whole point of looking for a converter was that when I connected to the bulb through the firmware console, 0,0,0,255 got me white and 255,0,0,0 got me red. the other locations blue and green.

I'd still really like a graphical color picker for the dashboard but I'm not sure I can make it work. I am going to try to append a 0 at the end of the color picker payload before it goes out to the light, and then have a separate white button.

I might just have to settle for 8 or 16 defined colors. I will be sure to buy RGB bulbs in the future for sure.

Thanks for your input @cymplecy.

this may start to get you there

[{"id":"777ea702.884008","type":"inject","z":"db8bd33.4e7c83","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":220,"wires":[["402f7510.7bfe5c"]]},{"id":"402f7510.7bfe5c","type":"ui_slider","z":"db8bd33.4e7c83","name":"","label":"W","tooltip":"","group":"d4ffd462.f30fb8","order":2,"width":"1","height":"4","passthru":true,"outs":"all","topic":"","min":0,"max":"255","step":1,"x":110,"y":280,"wires":[["ff441c7.8d04ce"]]},{"id":"ff441c7.8d04ce","type":"change","z":"db8bd33.4e7c83","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.w","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":280,"wires":[["d8909c77.bbd44"]]},{"id":"d8909c77.bbd44","type":"join","z":"db8bd33.4e7c83","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":280,"wires":[["72e881e9.cae6d"]]},{"id":"d27dec50.4e3e1","type":"ui_colour_picker","z":"db8bd33.4e7c83","name":"","label":"RGB","group":"d4ffd462.f30fb8","format":"rgb","outformat":"object","showSwatch":true,"showPicker":true,"showValue":true,"showHue":false,"showAlpha":false,"showLightness":true,"dynOutput":"false","order":1,"width":"5","height":"4","passthru":true,"topic":"","x":290,"y":220,"wires":[["d8909c77.bbd44"]]},{"id":"72e881e9.cae6d","type":"csv","z":"db8bd33.4e7c83","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"r,g,b,w","skip":"0","x":590,"y":280,"wires":[["5c71570d.4b0358"]]},{"id":"5c71570d.4b0358","type":"debug","z":"db8bd33.4e7c83","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":630,"y":200,"wires":[]},{"id":"d4ffd462.f30fb8","type":"ui_group","z":"","name":"Default","tab":"2a823ed1.c567e2","disp":true,"width":"6","collapse":false},{"id":"2a823ed1.c567e2","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

Thanks! @dceejay Going to try that once the sun goes down.

@dceejay - Not only did it get me there, it's fully functional! Thank you! I should share my flow with you for fun.... I'm still in the stage where I don't know what I don't know yet. I was on the path in the general right direction but how you did it was way more elegant, and ultimately actually functional.

@dceejay --- Would you take a quick peek at the additions to the node you made - I modified it so that when the white led is toggled on, it sets the color picker node to (0,0,0), and that works great. I'm also trying to get the reverse to work -- that if i choose a color from the color picker, it turns off the white led at the switch. That one I'm missing something. I copied the if statement function from the NR documentation

Once this is done, I'd consider it finished and publishable as a flow, albeit a flow for super beginners.

EDIT: Also, if this is where you tell me to learn Javascript... i'm cool with that too.

[{"id":"2f6a646d.7c68fc","type":"change","z":"9b6d369f.3f2518","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.w","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":420,"wires":[["cf5a3583.e25548"]]},{"id":"cf5a3583.e25548","type":"join","z":"9b6d369f.3f2518","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":420,"wires":[["61113caf.ae6394"]]},{"id":"f9cca833.ff4738","type":"ui_colour_picker","z":"9b6d369f.3f2518","name":"","label":"RGB","group":"a8dadd2e.e3477","format":"rgb","outformat":"object","showSwatch":true,"showPicker":true,"showValue":true,"showHue":false,"showAlpha":false,"showLightness":true,"dynOutput":"false","order":1,"width":"5","height":"4","passthru":true,"topic":"","x":570,"y":360,"wires":[["cf5a3583.e25548","a99bf359.6fe38","a260f675.d7fc38"]]},{"id":"61113caf.ae6394","type":"csv","z":"9b6d369f.3f2518","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"r,g,b,w","skip":"0","x":870,"y":420,"wires":[["3c85b400.ababac"]]},{"id":"a260f675.d7fc38","type":"debug","z":"9b6d369f.3f2518","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":910,"y":340,"wires":[]},{"id":"3c85b400.ababac","type":"mqtt out","z":"9b6d369f.3f2518","name":"Change Color","topic":"cmnd/MerkuryA21/color","qos":"","retain":"","broker":"dbea0116.71f43","x":1080,"y":420,"wires":[]},{"id":"8de890d8.89f4b","type":"ui_switch","z":"9b6d369f.3f2518","name":"White Switch","label":"White LED's","tooltip":"","group":"a8dadd2e.e3477","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"255","onvalueType":"num","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":130,"y":440,"wires":[["db1ca2ac.b714d","2f6a646d.7c68fc"]]},{"id":"db1ca2ac.b714d","type":"function","z":"9b6d369f.3f2518","name":"set rgb to 0,0,0 if white is on","func":"if (msg.payload === 255) {\n   return [ msg, null ];\n} else {\n   return [ \"0,0,0\", msg ];\n}\nreturn msg;","outputs":1,"noerr":0,"x":240,"y":360,"wires":[["f9cca833.ff4738"]]},{"id":"a99bf359.6fe38","type":"function","z":"9b6d369f.3f2518","name":"if RGB is not 0,0,0, turn off white switch","func":"if (msg.payload === \"0,0,0\") {\n   return [\"false\", msg ];\n} else {\n   return [  msg, null ];\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":200,"y":300,"wires":[["8de890d8.89f4b"]]},{"id":"b9f336c6.3ca8f8","type":"comment","z":"9b6d369f.3f2518","name":"does not work ","info":"","x":90,"y":280,"wires":[]},{"id":"5cc0eeae.ca294","type":"comment","z":"9b6d369f.3f2518","name":"works","info":"","x":370,"y":340,"wires":[]},{"id":"a8dadd2e.e3477","type":"ui_group","z":"","name":"Default","tab":"3c270a60.dc4106","disp":true,"width":"6","collapse":false},{"id":"dbea0116.71f43","type":"mqtt-broker","z":"","name":"","broker":"10.0.0.7","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"nodered/status/on","birthQos":"0","birthPayload":"Nodered is Turned ON","closeTopic":"nodered/status/off","closePayload":"Noderedis Turned OFF","willTopic":"nodered/status/on","willQos":"0","willPayload":"Node-red LWT "},{"id":"3c270a60.dc4106","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

So your function code doesn't work. You need to look at the data coming into it. put a debug node on the output of the node feeding the function node.

Is the data getting to the function what you expect?

1 Like

Also both functions are set to return two outputs ( return ["false", msg ]; ) etc - but the nodes have only one output... not sure if this is intentional or not... :slight_smile:

1 Like