Node Red compare array

Hi All,
I thought this was going to be simple but not having much luck.
What i want is if the TV is paused and my lights are already a set color and brightness (set from a scene), then increase the brightness. If then the TV is unpaused then set brightness back down.

As this is from scene i know the values,
When TV pause is set, if light state on and brightness: 15 and rgb_color:[0,0,255]
Then set light brightness 255
When TV resumed if light state on and brightness: 255 and rgb_color:[0,0,255]
Then set light brightness 15

If this light was not already set to this scene then don’t change. (dull blue being move “Movie mode”)
The triggers are easy enough as doing on state changed, but i cannot get the if rgb_color:[0,0,255] to work, testing the strings or numbers are easy enough but i have not been able to work out how to compare against an array.

Any pointers as to which node(s) to use and how to set it would be great as tried all sorts of combinations.

I had to do a compare of 2 sensors as well. what i ended up doing was using 2 state change nodes, each fed into a function both of those functions fed into an and-gate node and then automate from there (node–red-contrib-bool-gate) there may be a better way to do it. but that is what worked for me.

Thanks, even in the function how do I compare array of rgb_color?

Not the OP also not using a function node but you can flatten the array with JSONATA in achange node and use switch node afterwards. something like this:

[{"id":"d623f800.1435f8","type":"inject","z":"294e4f5f.46b07","name":"","topic":"","payload":"{\"RGB\":[0,0,150]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":260,"wires":[["2794ab21.f76954"]]},{"id":"5cdc7076.fd687","type":"debug","z":"294e4f5f.46b07","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":240,"wires":[]},{"id":"4a0f5334.f11f3c","type":"switch","z":"294e4f5f.46b07","name":"","property":"payload.RGB","propertyType":"msg","rules":[{"t":"eq","v":"00255","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":260,"wires":[["5cdc7076.fd687"],["cbc77bad.7c22f8"]]},{"id":"2794ab21.f76954","type":"change","z":"294e4f5f.46b07","name":"","rules":[{"t":"set","p":"payload.RGB","pt":"msg","to":"payload.RGB[0]&payload.RGB[1]&payload.RGB[2]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":260,"wires":[["4a0f5334.f11f3c"]]},{"id":"cbc77bad.7c22f8","type":"debug","z":"294e4f5f.46b07","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":280,"wires":[]}]
1 Like

worked perfectly, few more steps than i was thinking of as now using 3 node including current state then the suggested conversion. Just to see if light is blue.
Thank you very much