Time of day schedule builder with Node-Red

I have been using bigtimer in node red to set schedules for daily house routines, (Morning/Day/Evening/Night). However the wife wanted to be able to change the schedule on the fly from time to time so I have started using a settings tab which can control things like season, (influences HVAC/Chirstmas Lights/etc.), schedules, house mode etc.

As part of this I put together a simple schedule form that pushes into Node-Red. I used schedex in Node-Red as it allows for having default times and passing in new values in the flow to change start time etc.

Here is the schedule from the settings tab in HA:
image

Here is the flow diagram from Node-Red

And lastly here is the flow:

[{"id":"1ecce0b4.e2fc1f","type":"server-state-changed","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"entityidfilter":"input_datetime.start_morning","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":200,"y":1280,"wires":[["5b8ceb9.2419414","1f277a03.2e0806","ad43838e.0509"]]},{"id":"5b8ceb9.2419414","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":1260,"wires":[]},{"id":"44db40a0.7fd48","type":"schedex","z":"ca2305ba.3a64f8","name":"Morning Scene Schedule","suspended":false,"lat":"","lon":"","ontime":"05:30:00","ontopic":"morning_enabled","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"09:30:00","offtopic":"morning_enabled","offpayload":"off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":850,"y":1270,"wires":[["6b8ccac7.2e7b84"]]},{"id":"1f277a03.2e0806","type":"change","z":"ca2305ba.3a64f8","name":"Set Time on Override","rules":[{"t":"set","p":"ontime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.ontime","pt":"msg","to":"ontime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1300,"wires":[["44db40a0.7fd48","52956e9b.aa08c"]]},{"id":"52956e9b.aa08c","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":1330,"wires":[]},{"id":"6b8ccac7.2e7b84","type":"switch","z":"ca2305ba.3a64f8","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":1100,"y":1260,"wires":[["a4032f27.6330a","10cd39d2.d7f2f6"],[]]},{"id":"a4032f27.6330a","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":1230,"wires":[]},{"id":"10cd39d2.d7f2f6","type":"api-call-service","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.house_mode","data":"{\"option\":\"Morning\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1350,"y":1270,"wires":[["4ff9154b.9d96cc"]]},{"id":"c4c6a5c1.a75278","type":"server-state-changed","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"entityidfilter":"input_datetime.start_day","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":180,"y":1430,"wires":[["a47e3874.c5ce28","c3509e71.f486b","1015b6ae.290509"]]},{"id":"a47e3874.c5ce28","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":1460,"wires":[]},{"id":"5ff5307f.3b464","type":"schedex","z":"ca2305ba.3a64f8","name":"Day Scene Schedule","suspended":false,"lat":"","lon":"","ontime":"09:00","ontopic":"day_enabled","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"17:00:00","offtopic":"day_enabled","offpayload":"off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":830,"y":1420,"wires":[["d24c054.6a007f8"]]},{"id":"c3509e71.f486b","type":"change","z":"ca2305ba.3a64f8","name":"Set Time on Override","rules":[{"t":"set","p":"ontime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.ontime","pt":"msg","to":"ontime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1500,"wires":[["5ff5307f.3b464","e7cfdef6.ecad5"]]},{"id":"e7cfdef6.ecad5","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":780,"y":1480,"wires":[]},{"id":"d24c054.6a007f8","type":"switch","z":"ca2305ba.3a64f8","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":1090,"y":1410,"wires":[["714aab37.d23714","a20001bd.3aa9e"],[]]},{"id":"714aab37.d23714","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1270,"y":1380,"wires":[]},{"id":"a20001bd.3aa9e","type":"api-call-service","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.house_mode","data":"{\"option\":\"Day\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1340,"y":1420,"wires":[["d4c451a2.7a4a3"]]},{"id":"1015b6ae.290509","type":"change","z":"ca2305ba.3a64f8","name":"Set Time off Override","rules":[{"t":"set","p":"offtime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.offtime","pt":"msg","to":"offtime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1400,"wires":[["44db40a0.7fd48"]]},{"id":"37f0d58a.ae40ba","type":"server-state-changed","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"entityidfilter":"input_datetime.start_evening","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":190,"y":1590,"wires":[["9ab46a2.ec42298","33556f47.76ffa","e110f417.fe8b28"]]},{"id":"9ab46a2.ec42298","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":540,"y":1620,"wires":[]},{"id":"99ab4b50.47e348","type":"schedex","z":"ca2305ba.3a64f8","name":"Evening Scene Schedule","suspended":false,"lat":"","lon":"","ontime":"17:00","ontopic":"evening_enabled","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"23:30","offtopic":"evening_enabled","offpayload":"off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":850,"y":1580,"wires":[["c131c94c.a042f8"]]},{"id":"33556f47.76ffa","type":"change","z":"ca2305ba.3a64f8","name":"Set Time on Override","rules":[{"t":"set","p":"ontime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.ontime","pt":"msg","to":"ontime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1660,"wires":[["99ab4b50.47e348","54542ffe.0068d"]]},{"id":"54542ffe.0068d","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":1640,"wires":[]},{"id":"c131c94c.a042f8","type":"switch","z":"ca2305ba.3a64f8","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":1100,"y":1570,"wires":[["1f60fd14.eb4143","f59fb257.a8329"],[]]},{"id":"1f60fd14.eb4143","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1280,"y":1540,"wires":[]},{"id":"f59fb257.a8329","type":"api-call-service","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.house_mode","data":"{\"option\":\"Evening\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1350,"y":1580,"wires":[["d47a1fd6.72305"]]},{"id":"e110f417.fe8b28","type":"change","z":"ca2305ba.3a64f8","name":"Set Time off Override","rules":[{"t":"set","p":"offtime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.offtime","pt":"msg","to":"offtime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1560,"wires":[["5ff5307f.3b464"]]},{"id":"7a534908.9acfd8","type":"server-state-changed","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"entityidfilter":"input_datetime.start_night","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":180,"y":1740,"wires":[["56a0920f.91bd0c","d3f42393.4718c","63c5c208.8754ec"]]},{"id":"56a0920f.91bd0c","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":540,"y":1770,"wires":[]},{"id":"4cd93ac1.091614","type":"schedex","z":"ca2305ba.3a64f8","name":"Night Scene Schedule","suspended":false,"lat":"","lon":"","ontime":"23:30","ontopic":"night_enabled","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"05:00","offtopic":"night_enabled","offpayload":"off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":840,"y":1730,"wires":[["2b9a2fd4.51ca6"]]},{"id":"d3f42393.4718c","type":"change","z":"ca2305ba.3a64f8","name":"Set Time on Override","rules":[{"t":"set","p":"ontime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.ontime","pt":"msg","to":"ontime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1810,"wires":[["4cd93ac1.091614","11d0df1e.e942f1"]]},{"id":"11d0df1e.e942f1","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":1790,"wires":[]},{"id":"2b9a2fd4.51ca6","type":"switch","z":"ca2305ba.3a64f8","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":1100,"y":1720,"wires":[["c695abf9.f7f688","a6a5d497.ada638"],[]]},{"id":"c695abf9.f7f688","type":"debug","z":"ca2305ba.3a64f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1260,"y":1690,"wires":[]},{"id":"a6a5d497.ada638","type":"api-call-service","z":"ca2305ba.3a64f8","name":"","server":"65b61d5d.d1e1c4","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.house_mode","data":"{\"option\":\"Night\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1350,"y":1730,"wires":[["f2cc862e.224718"]]},{"id":"63c5c208.8754ec","type":"change","z":"ca2305ba.3a64f8","name":"Set Time off Override","rules":[{"t":"set","p":"offtime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.offtime","pt":"msg","to":"offtime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1710,"wires":[["99ab4b50.47e348"]]},{"id":"ad43838e.0509","type":"change","z":"ca2305ba.3a64f8","name":"Set Time off Override","rules":[{"t":"set","p":"offtime","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.offtime","pt":"msg","to":"offtime","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1220,"wires":[["4cd93ac1.091614"]]},{"id":"4ff9154b.9d96cc","type":"change","z":"ca2305ba.3a64f8","name":"Telegram Morning","rules":[{"t":"set","p":"notification_txt","pt":"msg","to":"Morning Scene Enabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1260,"wires":[["d9b8c67c.f38f68"]]},{"id":"d9b8c67c.f38f68","type":"link out","z":"ca2305ba.3a64f8","name":"Notify Morning Scene","links":["a69a61fd.e1ff7"],"x":1795,"y":1260,"wires":[]},{"id":"d4c451a2.7a4a3","type":"change","z":"ca2305ba.3a64f8","name":"Telegram Day","rules":[{"t":"set","p":"notification_txt","pt":"msg","to":"Day Scene Enabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1420,"wires":[["5aaebe8a.76f3e"]]},{"id":"5aaebe8a.76f3e","type":"link out","z":"ca2305ba.3a64f8","name":"Notify Morning Scene","links":["a69a61fd.e1ff7"],"x":1805,"y":1420,"wires":[]},{"id":"d47a1fd6.72305","type":"change","z":"ca2305ba.3a64f8","name":"Telegram Evening","rules":[{"t":"set","p":"notification_txt","pt":"msg","to":"Evening Scene Enabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1580,"wires":[["123e8548.5414db"]]},{"id":"123e8548.5414db","type":"link out","z":"ca2305ba.3a64f8","name":"Notify Morning Scene","links":["a69a61fd.e1ff7"],"x":1795,"y":1580,"wires":[]},{"id":"f2cc862e.224718","type":"change","z":"ca2305ba.3a64f8","name":"Telegram Night","rules":[{"t":"set","p":"notification_txt","pt":"msg","to":"Night Scene Enabled","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1640,"y":1730,"wires":[["6e011ed6.fcc35"]]},{"id":"6e011ed6.fcc35","type":"link out","z":"ca2305ba.3a64f8","name":"Notify Morning Scene","links":["a69a61fd.e1ff7"],"x":1815,"y":1730,"wires":[]},{"id":"65b61d5d.d1e1c4","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

Hope this helps someone. For all my Node-Red stuff you can go to https://github.com/crzykidd/nodered-homeassistant

2 Likes

Thanks! great post and u

1 Like