# Flow not working as expected

**URL:** <https://discourse.nodered.org/t/flow-not-working-as-expected/87511>\
**Category:** General\
**Created:** [26 April 2024 08:14 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511 "2024-04-26T08:14:26Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 08:14 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/1 "2024-04-26T08:14:26Z")

</div>

hay there i trying to get this flow to work what i want is that at 9 a light turns on either green or purple depending on the days then after 1 houre it should turn blue but i cant get it to work

```auto
[{"id":"be5443ab497da02e","type":"light-scheduler","z":"02e19e0a42d671d1","settings":"1c3bef61c14711a3","events":"[{\"start\":{\"dow\":1,\"mod\":540},\"end\":{\"dow\":1,\"mod\":1170}},{\"start\":{\"dow\":2,\"mod\":540},\"end\":{\"dow\":2,\"mod\":1170}},{\"start\":{\"dow\":3,\"mod\":540},\"end\":{\"dow\":3,\"mod\":1170}},{\"start\":{\"dow\":4,\"mod\":540},\"end\":{\"dow\":4,\"mod\":1170}},{\"start\":{\"dow\":5,\"mod\":540},\"end\":{\"dow\":5,\"mod\":1170}},{\"start\":{\"dow\":6,\"mod\":540},\"end\":{\"dow\":6,\"mod\":1170}},{\"start\":{\"dow\":0,\"mod\":540},\"end\":{\"dow\":0,\"mod\":1170}}]","topic":"","name":"Basalt Cae Notification light","onPayload":"ON","onPayloadType":"str","offPayload":"OFF","offPayloadType":"str","onlyWhenDark":false,"scheduleRndMax":0,"sunElevationThreshold":6,"sunShowElevationInStatus":false,"outputfreq":"output.statechange.startup","x":1040,"y":480,"wires":[["f25308af8fb7a421"]]},{"id":"f25308af8fb7a421","type":"switch","z":"02e19e0a42d671d1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":480,"wires":[["278226e96a8258a6"],["bf4d7768c88d21a6"]]},{"id":"bf4d7768c88d21a6","type":"api-call-service","z":"02e19e0a42d671d1","name":"Basalt Cave Notification","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1290,"y":540,"wires":[[]]},{"id":"515d08f1c4a80a7d","type":"inject","z":"02e19e0a42d671d1","name":"Light OFf","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":980,"y":540,"wires":[["bf4d7768c88d21a6"]]},{"id":"f2cddbf354c8db7e","type":"inject","z":"02e19e0a42d671d1","name":"Light On","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":980,"y":420,"wires":[["278226e96a8258a6"]]},{"id":"a592aae6349c100d","type":"comment","z":"02e19e0a42d671d1","name":"Basalt Cave Light Controll","info":"","x":1010,"y":360,"wires":[]},{"id":"84daa8a760756238","type":"inject","z":"02e19e0a42d671d1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Auto","payloadType":"str","x":790,"y":480,"wires":[["be5443ab497da02e"]]},{"id":"5a80ce8534448e0f","type":"api-call-service","z":"02e19e0a42d671d1","name":"Basalt Cave Notification","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"{\"color_name\":\"blue\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1710,"y":400,"wires":[[]]},{"id":"350c4b85b7adaa4f","type":"delay","z":"02e19e0a42d671d1","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1580,"y":360,"wires":[["5a80ce8534448e0f"]]},{"id":"09786dcc43a389b8","type":"api-call-service","z":"02e19e0a42d671d1","name":"Basalt Cave Notification","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"{\"color_name\":\"green\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1450,"y":400,"wires":[["350c4b85b7adaa4f"]]},{"id":"194e2b539975db09","type":"api-call-service","z":"02e19e0a42d671d1","name":"Basalt Cave Notification","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"{\"color_name\":\"purple\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1450,"y":440,"wires":[["e652b6b277b97723"]]},{"id":"eef8103b20b3d396","type":"api-call-service","z":"02e19e0a42d671d1","name":"Basalt Cave Notification","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"{\"color_name\":\"blue\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1710,"y":440,"wires":[[]]},{"id":"e652b6b277b97723","type":"delay","z":"02e19e0a42d671d1","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1580,"y":480,"wires":[["eef8103b20b3d396"]]},{"id":"278226e96a8258a6","type":"function","z":"02e19e0a42d671d1","name":"function 1","func":"// Get the current day of the week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)\nvar currentDay = new Date().getDay();\n\n// Check if it's Monday, Wednesday, or Thursday\nif (currentDay === 1 || currentDay === 3 || currentDay === 4) {\n // Set payload to \"green\" if it's one of those days\n msg.payload = \"green\";\n} else {\n // Set payload to \"blue\" for all other days\n msg.payload = \"purple\";\n}\n\n// Send the modified message\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":440,"wires":[["09786dcc43a389b8","194e2b539975db09"]]},{"id":"1c3bef61c14711a3","type":"light-scheduler-settings","name":"my settings","latitude":"52.0347992","longitude":"5.3436076"},{"id":"ede85cdfcf45429d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"numeric","statusMonth":"numeric","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m:s","enableGlobalContextStore":false}]

```

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [26 April 2024 08:22 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/2 "2024-04-26T08:22:25Z")

</div>

To be able to read your flow, you might like to read [How to post your flows](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506). The Forum changes characters when code is 'just pasted' into a post and will not import for people to test or review.

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 08:24 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/3 "2024-04-26T08:24:04Z")

</div>

i did that but aperantly incorrect thanks dident notice

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [26 April 2024 08:29 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/4 "2024-04-26T08:29:49Z")

</div>

There are also some nodes in the flow that are not recognised, or not available using 'Manage Palette'. Are you using HA or some other HEMS?

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 08:32 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/5 "2024-04-26T08:32:32Z")

</div>

im using the node red addon in HA i use light scheduler i think thats the only one that i installed myzelf

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 08:35 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/6 "2024-04-26T08:35:32Z")

</div>

in short what i want is that on certain days the light is either purple or green and a houre later it should be blue i want it to turn on at 9 and shut off at 22 i followed some instructions i found online but it dosent seem to work out for me

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [26 April 2024 08:46 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/7 "2024-04-26T08:46:45Z")

</div>

It might be useful for you to watch the Videos on YouTube - [Node Red Essentials](https://www.youtube.com/channel/UCQaB8NXBEPod7Ab8PPCLLAA). Time well invested to get a good basic understanding of Node RED.

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 08:47 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/8 "2024-04-26T08:47:50Z")

</div>

im gona do that thanks

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [26 April 2024 08:57 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/9 "2024-04-26T08:57:10Z")

</div>

I think you use Home Assistant so I'm not sure if this approach is relevant for you, but here is how I would do it in Node-red.

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

```auto
[{"id":"eef36127fb3734b9","type":"cronplus","z":"6ceceb16f2680417","name":"9pm: green or purple","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"Green","topic":"topic1","payloadType":"str","payload":"green","expressionType":"cron","expression":"0 0 21 ? * MON,WED,THU *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Purple","topic":"topic2","payloadType":"str","payload":"purple","expressionType":"cron","expression":"0 0 21 ? * TUE,FRI,SAT,SUN *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":220,"y":260,"wires":[["c9acc9a894fd8842"]]},{"id":"c9acc9a894fd8842","type":"trigger","z":"6ceceb16f2680417","name":"1 hour then blue","op1":"","op2":"blue","op1type":"pay","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"hr","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":440,"y":260,"wires":[[]]}]

```

On the left is a Cron Plus node which injects either "green" or "purple" at 9pm.  
It uses cron, a utility originally developed for regular event schedules in Unix.  
Cron is notoriously cryptic but the node has an "easy expression builder" which simplifies it a bit.  
You would need to install node-red-contrib-cron-plus to use this.

On the right a trigger node sends on the "green" or "purple" payload and 1 hour later sends "blue"

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 10:37 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/10 "2024-04-26T10:37:30Z")

</div>

okay cron seems to be working do i need to put this befor a call service im sorry if this is a dumb quistion im still watching Node-RED Essentials playlist

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [26 April 2024 10:41 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/11 "2024-04-26T10:41:48Z")

</div>

It is not dumb to ask questions!

Unfortunately I don't know the answer.  
My HomeAssistant knowledge can be summarised as

```auto
HomeAssistant? No thanks!

```

To expand on that a bit:

I can put Node-red on my Raspberry Pi and interface with all sorts of IOT devices, websites, databases etc and create a simple dashboard to present it all.

Or I can put an entire dedicated operating system on the Pi to do all that _and still need to install Node-red when things get a bit tricky_.

I really can't see the advantage. But there's lots of folk who love HomeAssistant so I'm probably just out of touch.

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 10:44 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/12 "2024-04-26T10:44:05Z")

</div>

this is my first time trying this all for keeps and everything i looked at was way to hard HA was about the only thing i could wrap my head around so im just gona try some stuff and see if it works

---

<div class="post-metadata">

**Author:** ![aredhone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aredhone/32/90359_2.png) [@aredhone](https://discourse.nodered.org/u/aredhone)\
**Post date:** [26 April 2024 11:04 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/13 "2024-04-26T11:04:12Z")

</div>

this

```auto
[{"id":"9131be2f42a3421a","type":"api-call-service","z":"974e85ac2d994845","name":"Green","server":"ede85cdfcf45429d","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.led_strip_rgb_w"],"data":"{\"color_name\":msg.payload}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":970,"y":360,"wires":[[]]},{"id":"c9acc9a894fd8842","type":"trigger","z":"974e85ac2d994845","name":"1 hour then blue","op1":"","op2":"blue","op1type":"pay","op2type":"str","duration":"15","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":790,"y":360,"wires":[["9131be2f42a3421a"]]},{"id":"eef36127fb3734b9","type":"cronplus","z":"974e85ac2d994845","name":"9am: green or purple","outputField":"payload","timeZone":"","storeName":"","commandResponseMsgOutput":"output1","defaultLocation":"","defaultLocationType":"default","outputs":1,"options":[{"name":"Green","topic":"topic1","payloadType":"str","payload":"Green","expressionType":"cron","expression":"0 0 9 ? * MON,WED,THU *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"Purple","topic":"topic2","payloadType":"str","payload":"Purple","expressionType":"cron","expression":"0 35 12 ? * TUE,FRI,SAT,SUN *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":570,"y":360,"wires":[["c9acc9a894fd8842","9131be2f42a3421a"]]},{"id":"ede85cdfcf45429d","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"numeric","statusMonth":"numeric","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m:s","enableGlobalContextStore":false}]

```

seems to be working thanks all

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 April 2024 11:26 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/14 "2024-04-26T11:26:46Z")

</div>

If you are not already using HA then I suggest ditching it before you get too involved. It will be much harder to get out of HA later if you decide that using node red stand alone is better.

---

<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:** [10 May 2024 11:26 UTC](https://discourse.nodered.org/t/flow-not-working-as-expected/87511/15 "2024-05-10T11:26:54Z")

</div>

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