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

**URL:** https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301
**Category:** General
**Created:** [21 November 2020 20:27 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301 "2020-11-21T20:27:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![TheSoulrester](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thesoulrester/32/37842_2.png) [@TheSoulrester](https://discourse.nodered.org/u/TheSoulrester)
#### Post date: [21 November 2020 20:27 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/1 "2020-11-21T20:27:01Z")

</div>

Hey 🙂

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 ☹ - despite i am changing the msg.payload on true to msg.payload on to false...

what am i doing wrong?

```auto
[{"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}]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [21 November 2020 21:19 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/2 "2020-11-21T21:19:31Z")

</div>

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

try this...

```auto
[{"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....

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35b911cef413830e07fdb634dcd650dbc4654f5e.png)

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

---

<div class="post-metadata">

### Author: ![TheSoulrester](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thesoulrester/32/37842_2.png) [@TheSoulrester](https://discourse.nodered.org/u/TheSoulrester)
#### Post date: [21 November 2020 21:56 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/3 "2020-11-21T21:56:13Z")

</div>

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

=\> 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 ☹

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

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [21 November 2020 22:00 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/4 "2020-11-21T22:00:01Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/addda791d93605e3e2d381193f9c2f03f829719c.png)

---

<div class="post-metadata">

### Author: ![TheSoulrester](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thesoulrester/32/37842_2.png) [@TheSoulrester](https://discourse.nodered.org/u/TheSoulrester)
#### Post date: [21 November 2020 22:24 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/5 "2020-11-21T22:24:33Z")

</div>

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 ☹ . i am still relatively new to node red 😉

Thanks for your help so far 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/4817c257c5e3cf36fdae2ffee3eabb1db260d6e0.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/9742f10da14569184443003cb562f2c0ee958b0f.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [21 November 2020 22:32 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/6 "2020-11-21T22:32:13Z")

</div>

> [@TheSoulrester](#):
>
> for this i use 2 gpio pins on my raspberry pi. the button inject is currently only for testing.

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)

> [@TheSoulrester](#):
>
> but for a reason unknown to me it is not triggered

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"

---

<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: [20 January 2021 22:32 UTC](https://discourse.nodered.org/t/hue-magic-state-on-false-does-not-work/36301/7 "2021-01-20T22:32:18Z")

</div>

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