Hue-Magic - State "On"= false does not work

Hey :slight_smile:

i want to temporarly change the light to a 33% brightness red. it should be round about 60s on. after the time it should take the same values as before and moreover the light should be switched off (if it was on the time before).

with this code, everathing works fine except switching the light off :frowning: - despite i am changing the msg.payload on true to msg.payload on to false...

what am i doing wrong?

[{"id":"ef6064e6.dad0d8","type":"inject","z":"26be794a.395f46","name":"Test-Alarm","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":140,"y":220,"wires":[["ecc0e09a.ade13","f2bb9819.a2d5e8","ad4185ba.b6fc18"]]},{"id":"b1edd01a.df2a6","type":"change","z":"26be794a.395f46","name":"","rules":[{"t":"set","p":"lampSetting1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":100,"wires":[[]]},{"id":"ecc0e09a.ade13","type":"delay","z":"26be794a.395f46","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":260,"wires":[["c468f00d.694ff"]]},{"id":"c468f00d.694ff","type":"function","z":"26be794a.395f46","name":"","func":"msg.payload = flow.get('lampSetting1');\nmsg.payload.on = false;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":260,"wires":[["ba71ab25.f8edf8"]]},{"id":"ba71ab25.f8edf8","type":"delay","z":"26be794a.395f46","name":"","pauseType":"delay","timeout":"59","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":790,"y":260,"wires":[["66ebf82b.be7238"]]},{"id":"f2bb9819.a2d5e8","type":"hue-light","z":"26be794a.395f46","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":410,"y":100,"wires":[["b1edd01a.df2a6"]]},{"id":"66ebf82b.be7238","type":"hue-light","z":"26be794a.395f46","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":1070,"y":260,"wires":[[]]},{"id":"ad4185ba.b6fc18","type":"function","z":"26be794a.395f46","name":"","func":"msg.payload={\"on\":true, \"brightness\":33, \"rgb\":[255,0,0]};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":180,"wires":[["d57b9c51.a111e"]]},{"id":"d57b9c51.a111e","type":"delay","z":"26be794a.395f46","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":580,"y":180,"wires":[["3e47be8d.bceed2"]]},{"id":"3e47be8d.bceed2","type":"hue-light","z":"26be794a.395f46","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":930,"y":180,"wires":[[]]},{"id":"f23cce56.c56e4","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.178.21","key":"VBq04UywCSYmPx5LVHmbAB07cRK4B1x0zPPQI5jY","interval":"3000","disableupdates":false}]

Instead of storing state in context & running parallel flows, connect things in series & use a single msg object.

try this...

[{"id":"ef6064e6.dad0d8","type":"inject","z":"a9fbaedc.8f9c1","name":"Test-Alarm","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":500,"y":880,"wires":[["f2bb9819.a2d5e8"]]},{"id":"b1edd01a.df2a6","type":"change","z":"a9fbaedc.8f9c1","name":"","rules":[{"t":"set","p":"current","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":880,"wires":[["ad4185ba.b6fc18","7dbb818.1bf338"]]},{"id":"ba71ab25.f8edf8","type":"delay","z":"a9fbaedc.8f9c1","name":"","pauseType":"delay","timeout":"59","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":670,"y":1040,"wires":[["729932b0.0772bc"]]},{"id":"f2bb9819.a2d5e8","type":"hue-light","z":"a9fbaedc.8f9c1","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":700,"y":880,"wires":[["b1edd01a.df2a6"]]},{"id":"66ebf82b.be7238","type":"hue-light","z":"a9fbaedc.8f9c1","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":990,"y":1040,"wires":[[]]},{"id":"ad4185ba.b6fc18","type":"function","z":"a9fbaedc.8f9c1","name":"","func":"msg.payload={\"on\":true, \"brightness\":33, \"rgb\":[255,0,0]};\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":670,"y":960,"wires":[["3e47be8d.bceed2","ba71ab25.f8edf8"]]},{"id":"3e47be8d.bceed2","type":"hue-light","z":"a9fbaedc.8f9c1","name":"Arbeitszimmer Decke 1","bridge":"f23cce56.c56e4","lightid":"1","colornamer":true,"skipevents":false,"universalevents":false,"x":990,"y":960,"wires":[[]]},{"id":"729932b0.0772bc","type":"function","z":"a9fbaedc.8f9c1","name":"","func":"msg.payload = msg.current;\nmsg.payload.on = false;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":1040,"wires":[["66ebf82b.be7238","7513f87c.fde8e8"]]},{"id":"7dbb818.1bf338","type":"debug","z":"a9fbaedc.8f9c1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":820,"wires":[]},{"id":"7513f87c.fde8e8","type":"debug","z":"a9fbaedc.8f9c1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":1100,"wires":[]}]

Note: I dont have a hue nor do i have this node installed (so it may not re-import correctly) so here is a screenshot describing the potential solution....

check the debug nodes outputs to ensure correct data is being sent.

uhh ahm... now it gets triggert everytime the status of the bulb is chaning :smiley:

=> deploy the node => lamp gets red => after 59s, the lamp changes is status - but ic changing instant to red 33% again because of the flow neighbourhood relationship :frowning:

Ah, ok, i wasnt aware that node provide status without the inject.

Is there any difference between asking of the status & getting a status update automatically?

you could use a switch node to NOT trigger the rest of the flow if it is a auto status update.

Perhaps add a topic to the INJECT ( e.g. "manual" ) & if msg.topic is != "manual", dont do the 60s part of the flow.

image

I may explain my intentions.
i am a volunteer firefighter and would like the light to turn red for 1 minute at night when my detector at home triggers an alarm. afterwards, the light should go out. however, the old value that was set before the alarm should be taken over again. currently, the light stayed red and went off. however, as soon as i manually turned on the light again, it was still red due to the alarm

for this i use 2 gpio pins on my raspberry pi. the button inject is currently only for testing.

i have now added another msg.manual and an if-element. but for a reason unknown to me it is not triggered :frowning: . i am still relatively new to node red :wink:

Thanks for your help so far :slight_smile:


image

I guess that the inject was for testing but you can just as easily use a change node (placed after the GPIO) to set the topic (or msg.manual if you wish)

What is "not triggered"?

Try to get it working as expected with inject nodes first (as you are doing) and then it should be pretty easy to change to the GPIO

NOTE: it might be that hue node is not playing nicely. Put a debug AFTER the first Hue node (Decke 1) - does the injected topic (and / or msg.manual) get passed through from the inject to the debug?

NOTE2: To see msg.manual you will need to set the debug node to show "complete message"

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