Node Red: Send notification when washing machine energy consumption drops below threshold for time

Hey guys,

I’m really new to node red and Im trying to figure out how to make this work.

So if the power consumption is higher then 100 for more then 15m, then drops below 100. send a notification though alexa media centre, and then send it again every 15m until the laundry door is open.

It sounds easy enough HAHA, I’m trying to find something similar, but I just cant find anything.

Any help would be great :slight_smile:

[{"id":"f869758f.151ee8","type":"server-state-changed","z":"854e1af.ce97fe8","name":"State is > 100 for 15m","server":"d272ac3c.e0735","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.washing_machine","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"new_state.attributes.current > 100","halt_if_type":"jsonata","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"15","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":100,"y":660,"wires":[["9cbf9950.a5d668"],[]]},{"id":"9cbf9950.a5d668","type":"ha-wait-until","z":"854e1af.ce97fe8","name":"Wait till < 100 for 30s","server":"d272ac3c.e0735","outputs":2,"entityId":"switch.washing_machine","entityIdFilterType":"exact","property":"new_state.attributes.current","comparator":"lt","value":"100","valueType":"num","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":340,"y":660,"wires":[["d11cfebc.694cf"],[]]},{"id":"d11cfebc.694cf","type":"api-call-service","z":"854e1af.ce97fe8","name":"📢 Alexa","server":"d272ac3c.e0735","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"media_player.bedroom_echo_show, media_player.kitchen, media_player.bathroom","data":"{\"message\":\"Please take the washing out?\",\"data\":{\"type\":\"announce\"}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":540,"y":660,"wires":[["9d7a37c5.019ee8"]]},{"id":"d1a338d3.1c84d8","type":"api-call-service","z":"854e1af.ce97fe8","name":"Washing still in machine","server":"cc436e5e.bbf7e","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_all_speakers","entityId":"media_player.bedroom_echo_show, media_player.kitchen, media_player.bathroom","data":"{\"message\":\"Washing has been in the washing machine for {{minutes}} minutes\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1010,"y":700,"wires":[["56f6d599.93a1bc"]]},{"id":"56f6d599.93a1bc","type":"ha-wait-until","z":"854e1af.ce97fe8","name":"loop timer","server":"cc436e5e.bbf7e","outputs":2,"entityId":"binary_sensor.laundry_door_sensor_contact","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"15","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"data","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":800,"y":620,"wires":[["29c3515e.043bfe"],["9d7a37c5.019ee8"]]},{"id":"9d7a37c5.019ee8","type":"change","z":"854e1af.ce97fe8","name":"","rules":[{"t":"set","p":"minutes","pt":"msg","to":"$round(data.timeSinceChangedMs / 60000,0)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":700,"wires":[["d1a338d3.1c84d8"]]},{"id":"29c3515e.043bfe","type":"api-call-service","z":"854e1af.ce97fe8","name":"Washing has been taken out","server":"cc436e5e.bbf7e","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"media_player.bedroom_echo_show, media_player.kitchen, media_player.bathroom","data":"{\"message\":\"Washing has been taken out\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1080,"y":600,"wires":[[]]},{"id":"d272ac3c.e0735","type":"server","name":"Home Assistant","addon":true},{"id":"cc436e5e.bbf7e","type":"server","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

I think I might have it, would appreciate any Node Red gurus having a look?

I don’t want to write it for you because the fun is in troubleshooting and learning.

Without me opening Node-Red you should be able to do something like this:

Trigger node if consumption is higher than 100, wait node for 15 minutes and doo check on value or drops below 100. Do loop every 15 mins until door equals open.

When I have time if your still stuck I’ll write a flow up.

I’m no guru and probably there’s a better option, but this will work. If you restart either HA on Node Red while any of the two “wait until” nodes are waiting, you’ll break the flow. If you want to be safe against restarts, you should better create a separate flow for the TTS part, but I don’t believe you need it unless you are constantly restarting. If the door isn’t opened for 15 minutes, it resends the message. If you open it, it does nothing and the flow stops there.

[{"id":"1ba12555.985e7b","type":"server-state-changed","z":"3596e818.12bb08","name":"Sensor","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.power_consumption","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"100","halt_if_type":"num","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":true,"for":"15","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":130,"y":180,"wires":[["63e6c76f.fea698"],[]]},{"id":"63e6c76f.fea698","type":"ha-wait-until","z":"3596e818.12bb08","name":"<= 100?","server":"9405c3fe.d0a6c","outputs":1,"entityId":"sensor.power_consumption","entityIdFilterType":"exact","property":"state","comparator":"lt","value":"100","valueType":"num","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":280,"y":180,"wires":[["1308991e.dd68c7"]]},{"id":"1308991e.dd68c7","type":"api-call-service","z":"3596e818.12bb08","name":"TTS","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":440,"y":180,"wires":[["5e6c36c6.f8d698"]]},{"id":"5e6c36c6.f8d698","type":"ha-wait-until","z":"3596e818.12bb08","name":"Door open?","server":"9405c3fe.d0a6c","outputs":2,"entityId":"binary_sensor.laundry_door","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"15","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":580,"y":240,"wires":[[],["1308991e.dd68c7"]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","addon":true}]

Thanks guys!

Appreciate the help :slight_smile:

I think I might have it, but Ill have to wait till tomorrow to test it now.

Ill let you know

I believe the “Initial notification” output should be bound to the “loop timer (Door Open)” input

Is this working fine for you? Would you mind sharing the flow? I’m new to Node Red and looking for a way to send notifications to my Sonos speaker when the washing machine is finished. First an initial message, then if the door hasn’t been opened continue sending notifications like “The laundry is finished and has been in the machine for 45 minutes”

Hey,

Its not working for me right now, but thats because ive just moved lol.

Here is my notification for the washing machine. Im using Alexa media player for this. No idea about Sonos

[{"id":"a836d34420192a09","type":"server-state-changed","z":"6374ca0bbd7811ef","name":"Is the Washing Machine Clean?","server":"d272ac3c.e0735","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.washing_machine_status","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"Clean","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"10","forType":"num","forUnits":"minutes","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":130,"y":280,"wires":[["624eeb9411d92c9d"],[]]},{"id":"8bfd66e6410e2ace","type":"api-current-state","z":"6374ca0bbd7811ef","name":"Did person get home?","server":"d272ac3c.e0735","version":3,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"person.person","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"10","forType":"num","forUnits":"minutes","x":320,"y":360,"wires":[["d163173edca45d61"],["24c71091317545e8"]]},{"id":"624eeb9411d92c9d","type":"api-current-state","z":"6374ca0bbd7811ef","name":"Did person2 get Home?","server":"d272ac3c.e0735","version":3,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","entity_id":"person.person2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"10","forType":"num","forUnits":"minutes","x":450,"y":240,"wires":[["d163173edca45d61"],["8bfd66e6410e2ace"]]},{"id":"24c71091317545e8","type":"delay","z":"6374ca0bbd7811ef","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":490,"y":440,"wires":[["624eeb9411d92c9d"]]},{"id":"d163173edca45d61","type":"time-range-switch","z":"6374ca0bbd7811ef","name":"930AM to 10PM","lat":"-33.924211898294686","lon":"151.1886483807575","startTime":"09:30","endTime":"22:00","startOffset":0,"endOffset":0,"x":740,"y":240,"wires":[["59a326f56866fecb"],["92df446c8594ee17"]]},{"id":"92df446c8594ee17","type":"delay","z":"6374ca0bbd7811ef","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":790,"y":360,"wires":[["d163173edca45d61"]]},{"id":"59a326f56866fecb","type":"api-current-state","z":"6374ca0bbd7811ef","name":"Has the Washing Machine been emptied?","server":"d272ac3c.e0735","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.laundry_door_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":1140,"y":360,"wires":[[],["c14601e84d06a771"]]},{"id":"90f0f163fa6569ed","type":"delay","z":"6374ca0bbd7811ef","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1270,"y":240,"wires":[["59a326f56866fecb"]]},{"id":"c14601e84d06a771","type":"api-call-service","z":"6374ca0bbd7811ef","name":"Washing Machine needs to be emptied","server":"d272ac3c.e0735","version":5,"debugenabled":false,"domain":"notify","service":"alexa_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"The Washing Machine has finished, please empty the Washing Machine\",\t\"data\":{\"type\":\"announce\", \"method\":\"speak\"},\t\"target\":[\"media_player.bedroom_show\",\"media_player.kitchen\",\"media_player.bathroom\"]\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1510,"y":340,"wires":[["90f0f163fa6569ed"]]},{"id":"d272ac3c.e0735","type":"server","name":"Home Assistant","version":4,"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":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]
2 Likes