State of Light in NodeRed - solved

Hello everyone,

I need your help. I have an RGB lamp which shows me the status of my automation.

Window open= white 50%
Light on= White 100%
Post = Green 100%

I can also see the information in debug mode. However, I can’t manage to set the switch so that it differentiates between the 3 states. Can you help me with this?

Hi are you trying to change the color of the light or are you trying detect when it changes color.

Hi i try to detect the light

Can you show the debug for the 3 different states?

light

window open

post

See if this will work for you.

[{"id":"6351f741eff63159","type":"switch","z":"60f2d2277843c698","name":"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"(data.attributes.rgb_color[0] = 255) and (data.attributes.rgb_color[1] = 182) and (data.attributes.rgb_color[2] = 119) and  (data.attributes.brightness = 5)","vt":"jsonata"},{"t":"jsonata_exp","v":"(data.attributes.rgb_color[0] = 255) and (data.attributes.rgb_color[1] = 182) and (data.attributes.rgb_color[2] = 119) and (data.attributes.brightness = 20)","vt":"jsonata"},{"t":"jsonata_exp","v":"(data.attributes.rgb_color[0] = 0) and (data.attributes.rgb_color[1] = 255) and (data.attributes.rgb_color[2] = 0)","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":3,"x":730,"y":1340,"wires":[["b10625333b054e5f"],["dcf9e80754532bcd"],["b075a6674acce194"]],"outputLabels":["light","window open","post"]},{"id":"b075a6674acce194","type":"debug","z":"60f2d2277843c698","name":"post","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":1400,"wires":[]},{"id":"dcf9e80754532bcd","type":"debug","z":"60f2d2277843c698","name":"window open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":1340,"wires":[]},{"id":"af3188b311041500","type":"debug","z":"60f2d2277843c698","name":"post","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":1400,"wires":[]},{"id":"b10625333b054e5f","type":"debug","z":"60f2d2277843c698","name":"light","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":1280,"wires":[]}]

Currently only the post status works. But I can get it to work using the syntax. Thank you very much Mikefila.

1 Like