Flow not working as expected

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

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

To be able to read your flow, you might like to read How to post your flows. The Forum changes characters when code is 'just pasted' into a post and will not import for people to test or review.

i did that but aperantly incorrect thanks dident notice

1 Like

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?

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

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

It might be useful for you to watch the Videos on YouTube - Node Red Essentials. Time well invested to get a good basic understanding of Node RED.

im gona do that thanks

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

[{"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"

1 Like

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

It is not dumb to ask questions!

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

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.

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

this

[{"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

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.