NodeRed Flow to control coffee maker

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

Yes.
Always try and minimize the polling.
Both because of load, and because of delays.

You load the system for no reason, and the action can’t happen sooner than the next poll.
So to get a responsive automation you need to poll more often, which gives more load to the system.

Polling is bad. Only use it when you have to.
The only place I know polling is good (or less bad) is if you have a sequence that started and you had to restart HA, adding a polling to the state means the flow can restart.

But that could also be accomplished with HA start event then current state node to “inject” in the flow.

Can’t comment on the rest since I don’t have time now.

Another thing I noticed from the image.
You can remove a lot of the switch nodes.

Using current state node if state is:
That gives you two outbound connections if true or false. That means the switch node is not needed.

Hello Hellis,

thank you for the fast respond.

With your input I could already clean up my flow.

[{"id":"9baa679dd442c836","type":"tab","label":"Coffee","disabled":false,"info":"","env":[]},{"id":"ef0c8c5bed65fd04","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"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":[["52469af4d8f46598"]]},{"id":"d7c091d153680f49","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Family // home","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"home","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":840,"y":320,"wires":[["eb6f971e38c879d0"],["917102e5f5dbe501"]]},{"id":"eb6f971e38c879d0","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Workday // on","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"on","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":1080,"y":300,"wires":[["753b91a5fa38d0c1"],["917102e5f5dbe501"]]},{"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","ef0c8c5bed65fd04"]]},{"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"]]},{"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":1310,"y":280,"wires":[[]]},{"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":650,"y":480,"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":650,"y":600,"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":500,"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":500,"y":600,"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":1310,"y":360,"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":685,"y":280,"wires":[["d7c091d153680f49"]]},{"id":"49782554bc8c4af7","type":"comment","z":"9baa679dd442c836","name":"##### Time Trigger with Time Selection #####","info":"","x":190,"y":80,"wires":[]},{"id":"8cf3f7053ccc2d7e","type":"stoptimer","z":"9baa679dd442c836","duration":"120","units":"Minute","payloadtype":"num","payloadval":"0","name":"Timer (2h)","x":540,"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":360,"y":860,"wires":[["8cf3f7053ccc2d7e"]]},{"id":"fb9e8425dab1aa1c","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":800,"wires":[]},{"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":890,"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":690,"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":"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":"fb99008318ef73ec","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":560,"wires":[]},{"id":"a6f620a0ce93c625","type":"api-current-state","z":"9baa679dd442c836","name":"Coffee_status // on","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"on","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":610,"y":340,"wires":[["5cae2e411c208731","d7c091d153680f49"],["917102e5f5dbe501"]]},{"id":"5cae2e411c208731","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":380,"wires":[]},{"id":"288d3045d62975f9","type":"trigger-state","z":"9baa679dd442c836","name":"Coffee_auto // on","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.coffee_auto","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":140,"y":380,"wires":[["14bf8f46871319e6","f07e1d28de07fb16","b9b9c87f713b972d"],["efa1f0d10453f4f9","fb99008318ef73ec"]]},{"id":"c044887cac83a87f","type":"trigger-state","z":"9baa679dd442c836","name":"Coffee_status // on","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.shelly_plug","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":150,"y":820,"wires":[["8cf3f7053ccc2d7e"],["537f177dd449b9c3"]]},{"id":"365c89890133c506","type":"trigger-state","z":"9baa679dd442c836","name":"input_Time","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_datetime.coffee_time","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":140,"y":200,"wires":[[],["4bd43af390771e4d"]]},{"id":"5a46c18a67561ac4","type":"trigger-state","z":"9baa679dd442c836","name":"sensor_Time","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.time","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":""}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","enableInput":false,"x":150,"y":140,"wires":[[],["52469af4d8f46598"]]},{"id":"2449f8bdf6277602","type":"trigger","z":"9baa679dd442c836","name":"Rep 10s","op1":"on","op2":"0","op1type":"str","op2type":"str","duration":"-10","extend":false,"overrideDelay":false,"units":"s","reset":"off","bytopic":"all","topic":"topic","outputs":1,"x":440,"y":340,"wires":[["a6f620a0ce93c625"]]},{"id":"14bf8f46871319e6","type":"delay","z":"9baa679dd442c836","name":"Dly 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":310,"y":340,"wires":[["2449f8bdf6277602"]]},{"id":"b9b9c87f713b972d","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":440,"wires":[]},{"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}]

Because I changed to the “trigger:state” node. I can no longer poll in an interval and had to implement a trigger node with a 10s interval.
Is there a better way to do something like this to update the nodes?
Maybe new “trigger:state” nodes with an enable/disable input which only triggers when the “auto mode” is active or the time trigger has fired? Maybe a state machine?

I would like to gain a generell idea how to implement certain problems.

Andi

I’m looking at your two top left nodes.
What are they doing? Are you comparing current time with “activation” time in an input_datetime?

That is the time node:

Yes that’s basically it.

I have a time sensor in HA with the current Time and a Helper (input_datetime). In NR I delete the seconds, join the massages and compare both times.

Didn’t recognize that NR has a separate node for exactly that :smile:
That is much easier😃

Thanks for the hint.

I think…

All this can be replaced with these two nodes:

You trigger on shelly plug is on, then delay for 2 hours and call a script.
Events state node:

This triggers when it has been on for two hours.

What is the purpose of this?

Is it in case family is not home anymore?
In that case have a trigger node to switch off if family leaves. I hope the weekdays doesn’t change during your brewing.

Because the repeating of that node means you put load on your system. It’s essentially the same as a polling node.

As I see it this is what you need:

[{"id":"d7c091d153680f49","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Family // home","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"home","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"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":760,"y":320,"wires":[["eb6f971e38c879d0"],["917102e5f5dbe501"]]},{"id":"eb6f971e38c879d0","type":"api-current-state","z":"9baa679dd442c836","name":"sensor_Workday // on","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"on","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"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1000,"y":300,"wires":[["753b91a5fa38d0c1"],["917102e5f5dbe501"]]},{"id":"753b91a5fa38d0c1","type":"api-call-service","z":"9baa679dd442c836","name":"start Coffee_auto","server":"5569c883.013d08","version":5,"debugenabled":false,"service":"turn_on","entityId":["input_boolean.coffee_auto"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":280,"wires":[[]]},{"id":"f07e1d28de07fb16","type":"api-call-service","z":"9baa679dd442c836","name":"Coffee_start","server":"5569c883.013d08","version":5,"debugenabled":false,"service":"turn_on","entityId":["switch.shelly_plug"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":480,"wires":[[]]},{"id":"efa1f0d10453f4f9","type":"api-call-service","z":"9baa679dd442c836","name":"Coffee_stop","server":"5569c883.013d08","version":5,"debugenabled":false,"service":"turn_off","entityId":["switch.shelly_plug"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":600,"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":500,"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":500,"y":600,"wires":[["efa1f0d10453f4f9"]]},{"id":"917102e5f5dbe501","type":"api-call-service","z":"9baa679dd442c836","name":"stop Coffee_auto","server":"5569c883.013d08","version":5,"debugenabled":false,"service":"turn_off","entityId":["input_boolean.coffee_auto"],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":360,"wires":[[]]},{"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":"fb99008318ef73ec","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":560,"wires":[]},{"id":"a6f620a0ce93c625","type":"api-current-state","z":"9baa679dd442c836","name":"Coffee_status // on","server":"5569c883.013d08","version":3,"outputs":2,"halt_if":"on","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"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":340,"wires":[["5cae2e411c208731","d7c091d153680f49"],["917102e5f5dbe501"]]},{"id":"5cae2e411c208731","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":380,"wires":[]},{"id":"288d3045d62975f9","type":"trigger-state","z":"9baa679dd442c836","name":"Coffee_auto // on","server":"5569c883.013d08","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"input_boolean.coffee_auto","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":140,"y":380,"wires":[["14bf8f46871319e6","f07e1d28de07fb16","b9b9c87f713b972d"],["efa1f0d10453f4f9","fb99008318ef73ec"]]},{"id":"14bf8f46871319e6","type":"delay","z":"9baa679dd442c836","name":"Dly 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":310,"y":340,"wires":[["a6f620a0ce93c625"]]},{"id":"b9b9c87f713b972d","type":"debug","z":"9baa679dd442c836","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":440,"wires":[]},{"id":"05b0b765e529be91","type":"server-state-changed","z":"9baa679dd442c836","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.shelly_plug","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"hours","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":740,"wires":[["4f803bae414a223c"],[]]},{"id":"4f803bae414a223c","type":"api-call-service","z":"9baa679dd442c836","name":"","server":"5569c883.013d08","version":5,"debugenabled":false,"service":"call_coffee_timer_notify","entityId":[],"data":"","dataType":"jsonata","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":570,"y":740,"wires":[[]]},{"id":"fd1f1497bb368a90","type":"trigger-state","z":"9baa679dd442c836","name":"","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"group.family","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"away","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":990,"y":420,"wires":[["917102e5f5dbe501"],[]]},{"id":"f1aebd0de5602bdb","type":"ha-time","z":"9baa679dd442c836","name":"","server":"4bbca37b.1700ec","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityId":"input_datetime.coffee_time","property":"state","offset":0,"offsetType":"num","offsetUnits":"minutes","randomOffset":false,"repeatDaily":false,"payload":"$entity().state","payloadType":"jsonata","debugenabled":true,"x":490,"y":280,"wires":[["d7c091d153680f49"]]},{"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},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Wow, thanks. Already this looks so much better/cleaner.

But I see one open use case.

  • When the auto mode ist on → machine ist on → I finished my brew
    → Than I turn off the shelly outlet manually. This would not turn off the auto mode automatically.

This was the reason for my 10s trigger. To refresh the Coffee_status and disable the auto mode. Its not a big deal because there is no way that the machine starts again automatically until the next time trigger sets off. To fix this I will add another Trigger:State for on-off change to stop the auto mode.