Hi there,
I build the following automation flow to control my coffee maker and it escalated quickly (I’m new to NR):
[{"id":"9baa679dd442c836","type":"tab","label":"Coffee","disabled":false,"info":"","env":[]},{"id":"1067304fcfe9c5b9","type":"poll-state","z":"9baa679dd442c836","name":"input time","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"1","updateIntervalType":"num","updateIntervalUnits":"hours","outputinitially":true,"outputonchanged":true,"entity_id":"input_datetime.coffee_time","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":160,"y":200,"wires":[["4bd43af390771e4d"]]},{"id":"ef0c8c5bed65fd04","type":"debug","z":"9baa679dd442c836","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":180,"wires":[]},{"id":"4bd43af390771e4d","type":"function","z":"9baa679dd442c836","name":"hh:mm","func":"\nvar timestring = msg.payload\n\nvar hh = timestring.slice(0, -6)\nvar mm = timestring.slice(3, -3)\n\nmsg.payload = hh + \":\" + mm\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":200,"wires":[["ef0c8c5bed65fd04","52469af4d8f46598"]]},{"id":"d7c091d153680f49","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Family","server":"5569c883.013d08","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"group.family","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":820,"y":340,"wires":[["9b63ea7fa0fbf10b"]]},{"id":"eb6f971e38c879d0","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Workday","server":"5569c883.013d08","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.workday_sensor","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1210,"y":300,"wires":[["5155a7e9b92576a3"]]},{"id":"7856bf64acae712a","type":"poll-state","z":"9baa679dd442c836","name":"sensor_Time","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputinitially":false,"outputonchanged":true,"entity_id":"sensor.time","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":170,"y":140,"wires":[["ef0c8c5bed65fd04","52469af4d8f46598"]]},{"id":"52469af4d8f46598","type":"join","z":"9baa679dd442c836","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":140,"wires":[["10e06aba473f94e0"]]},{"id":"20ec43929dd2fb0d","type":"debug","z":"9baa679dd442c836","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":180,"wires":[]},{"id":"10e06aba473f94e0","type":"function","z":"9baa679dd442c836","name":"compare","func":"var time_Select = msg.payload[\"input_datetime.coffee_time\"]\nvar time_Current = msg.payload[\"sensor.time\"]\n\nif (time_Select == time_Current) {\n result = 'true';\n } else {\n result = 'false';\n }\n \nmsg.payload = result\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":140,"wires":[["29a68fca7dde8f7d"]]},{"id":"29a68fca7dde8f7d","type":"switch","z":"9baa679dd442c836","name":"true","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":890,"y":140,"wires":[["93f9bce2297e363d","20ec43929dd2fb0d"]]},{"id":"9b63ea7fa0fbf10b","type":"switch","z":"9baa679dd442c836","name":"home/not_home","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"neq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1000,"y":340,"wires":[["eb6f971e38c879d0"],["917102e5f5dbe501"]]},{"id":"5155a7e9b92576a3","type":"switch","z":"9baa679dd442c836","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1370,"y":300,"wires":[["753b91a5fa38d0c1"],["917102e5f5dbe501"]]},{"id":"753b91a5fa38d0c1","type":"api-call-service","z":"9baa679dd442c836","name":"start Coffee_auto","server":"5569c883.013d08","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.coffee_auto"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1670,"y":360,"wires":[[]]},{"id":"cebed229054b91b9","type":"poll-state","z":"9baa679dd442c836","name":"Coffee_auto","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":true,"entity_id":"input_boolean.coffee_auto","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":90,"y":420,"wires":[["6e735711784fc558","cc9a9df64353e32c","fb99008318ef73ec"]]},{"id":"f07e1d28de07fb16","type":"api-call-service","z":"9baa679dd442c836","name":"Coffee_start","server":"5569c883.013d08","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.shelly_plug"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":500,"wires":[[]]},{"id":"efa1f0d10453f4f9","type":"api-call-service","z":"9baa679dd442c836","name":"Coffee_stop","server":"5569c883.013d08","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.shelly_plug"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":560,"wires":[[]]},{"id":"98d24354a83a7299","type":"inject","z":"9baa679dd442c836","name":"Inject_On","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":480,"wires":[["f07e1d28de07fb16"]]},{"id":"b5493dded8499e40","type":"inject","z":"9baa679dd442c836","name":"Inject_Off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":540,"wires":[["efa1f0d10453f4f9"]]},{"id":"917102e5f5dbe501","type":"api-call-service","z":"9baa679dd442c836","name":"stop Coffee_auto","server":"5569c883.013d08","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.coffee_auto"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1670,"y":440,"wires":[[]]},{"id":"93f9bce2297e363d","type":"link out","z":"9baa679dd442c836","name":"","mode":"link","links":["de79035d68072c03"],"x":1055,"y":140,"wires":[]},{"id":"de79035d68072c03","type":"link in","z":"9baa679dd442c836","name":"","links":["93f9bce2297e363d"],"x":115,"y":340,"wires":[["d7c091d153680f49"]]},{"id":"49782554bc8c4af7","type":"comment","z":"9baa679dd442c836","name":"##### Time Trigger with Time Selection #####","info":"","x":190,"y":80,"wires":[]},{"id":"c11551ee241e1c6e","type":"poll-state","z":"9baa679dd442c836","name":"Coffee_status","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":true,"entity_id":"switch.shelly_plug","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":150,"y":820,"wires":[["60540ab343315fce"]]},{"id":"d2e88ef3a66b255e","type":"switch","z":"9baa679dd442c836","name":"on/var","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"neq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":820,"wires":[["8cf3f7053ccc2d7e"],["537f177dd449b9c3"]]},{"id":"8cf3f7053ccc2d7e","type":"stoptimer","z":"9baa679dd442c836","duration":"120","units":"Minute","payloadtype":"num","payloadval":"0","name":"Timer (2h)","x":780,"y":820,"wires":[["fb9e8425dab1aa1c","7d72ecc2f3590c3a"],[]]},{"id":"537f177dd449b9c3","type":"change","z":"9baa679dd442c836","name":"payload_stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":860,"wires":[["8cf3f7053ccc2d7e"]]},{"id":"6e735711784fc558","type":"rbe","z":"9baa679dd442c836","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":230,"y":460,"wires":[["7e039f211d8ca5ea"]]},{"id":"fb9e8425dab1aa1c","type":"debug","z":"9baa679dd442c836","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":800,"wires":[]},{"id":"c8bd031e7dbb5ad7","type":"inject","z":"9baa679dd442c836","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":150,"y":720,"wires":[["60540ab343315fce"]]},{"id":"02cc3638bcde2317","type":"inject","z":"9baa679dd442c836","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":150,"y":760,"wires":[["60540ab343315fce"]]},{"id":"60540ab343315fce","type":"rbe","z":"9baa679dd442c836","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":310,"y":820,"wires":[["d2e88ef3a66b255e"]]},{"id":"7e527b69f22e49e0","type":"api-call-service","z":"9baa679dd442c836","name":"","server":"5569c883.013d08","version":5,"debugenabled":false,"domain":"script","service":"call_coffee_timer_notify","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":840,"wires":[[]]},{"id":"7d72ecc2f3590c3a","type":"switch","z":"9baa679dd442c836","name":"on","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":930,"y":840,"wires":[["7e527b69f22e49e0"]]},{"id":"2a49fde52b598e76","type":"comment","z":"9baa679dd442c836","name":"##### Coffee Timer Notification #####","info":"","x":170,"y":660,"wires":[]},{"id":"25c9aa2e58765b93","type":"comment","z":"9baa679dd442c836","name":"##### Additional Conditions #####","info":"","x":160,"y":280,"wires":[]},{"id":"7e039f211d8ca5ea","type":"switch","z":"9baa679dd442c836","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":460,"wires":[["f07e1d28de07fb16"],["efa1f0d10453f4f9"]]},{"id":"59be9c1861e58b06","type":"inject","z":"9baa679dd442c836","name":"Time Trigger","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"str","x":690,"y":100,"wires":[["29a68fca7dde8f7d"]]},{"id":"72b19282d5db9b54","type":"switch","z":"9baa679dd442c836","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":380,"wires":[["d7c091d153680f49"],["917102e5f5dbe501"]]},{"id":"fb99008318ef73ec","type":"debug","z":"9baa679dd442c836","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":250,"y":500,"wires":[]},{"id":"cc9a9df64353e32c","type":"delay","z":"9baa679dd442c836","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":230,"y":420,"wires":[["10f4b9ecf978d95b"]]},{"id":"a6f620a0ce93c625","type":"api-current-state","z":"9baa679dd442c836","name":"Coffee_status","server":"5569c883.013d08","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"switch.shelly_plug","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":500,"y":380,"wires":[["5cae2e411c208731","72b19282d5db9b54"]]},{"id":"5cae2e411c208731","type":"debug","z":"9baa679dd442c836","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":420,"wires":[]},{"id":"10f4b9ecf978d95b","type":"switch","z":"9baa679dd442c836","name":"on","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":420,"wires":[["a6f620a0ce93c625"]]},{"id":"5569c883.013d08","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
A short explanation:
- The flow checks if the current time ist equal to my helper input → than it checks additional conditions
- the flow checks if someone ist home and if it is a workday today → than it starts my “coffee auto mode”
- if the “auto mode” is on it checks every minute if the machine is still on, someone is still home and if its still a workday. if any condition fails it disables the auto mode
- depending on a change of the “auto mode” state it turns on/off the machine
- the lower third of the flow starts a timer to remind me after 2 hours that the coffee machine is still on
So far everything seems to work and I’m very happy that I can remove 5 different HA automations with a single flow.
But the flow ist somehow messy/hard to troubleshoot.
My question to more experienced NodeRed users:
- do you have any recommendations to optimize the flow/structer?
- lessons learned?
- best practice tips for me?
- do you use the “trigger:state” node instead of the “poll state” or “current state”
I would be happy to hear any recommendations from you.
Kind regards,
Andi