Node Red Leak Sensor Monitoring

I’ve recently installed a network of Zigbee sensors to monitor leaks throughout the house. I’m kind of proud of what I came up with and wanted to share not only to maybe benefit others, but solicit feedback on my logic and how it can be improved. I haven’t touched HA in a few years after I aborted it due to integrations constantly breaking in years past, so I’m still somewhat a newb. The two flows I have below do the following:

The first flow is rather simple. Monitor 12 leak sensors and look for state changes to “on” (wet). If detected it flashes lights in the house, sends a push notification to mobile devices and a tts announcement to multiple Sonos media_players throughout the house.

I look forward to everyone’s feedback.

[{"id":"d085a226ea6ad8f5","type":"comment","z":"fcdd7ca7c451f869","name":"Monitor all leak sensors for state changes. If \"Wet\" flash house lights, send notification to phones \\n and play an announcement in all rooms.","info":"","x":630,"y":280,"wires":[]},{"id":"397f963b40fd181e","type":"server-state-changed","z":"fcdd7ca7c451f869","name":"All Leak Sensors","server":"24905bcc.e675d4","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":["binary_sensor.sensor_leak_addition_sink_moisture","binary_sensor.sensor_leak_addition_bath_sink_moisture","binary_sensor.sensor_leak_addition_bath_toilet_moisture","binary_sensor.sensor_leak_master_bath_sink_left_moisture","binary_sensor.sensor_leak_master_bath_sink_right_moisture","binary_sensor.sensor_leak_master_bath_toilet_moisture","binary_sensor.sensor_leak_guestbath_sink_moisture","binary_sensor.sensor_leak_guestbath_toilet_moisture","binary_sensor.lumi_lumi_sensor_wleak_aq1_moisture","binary_sensor.sensor_leak_kitchen_sink_moisture_2","binary_sensor.sensor_leak_garage_utility_closet_moisture_2","binary_sensor.leak_kitchen_refer_moisture_2"],"entityIdType":"list","outputInitially":true,"stateType":"str","ifState":"on","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","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":440,"y":360,"wires":[["2372947223c10abe","fdfe2841c19b643f","7df1a157d5db4da2","06fb564716b71589"],[]]},{"id":"2372947223c10abe","type":"api-call-service","z":"fcdd7ca7c451f869","name":"Text Kevin","server":"24905bcc.e675d4","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_ikevin15pro","areaId":[],"deviceId":[],"entityId":[],"data":"{\"title\":\"Leak Detected!!\",\"message\":\"Device {{topic}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":380,"wires":[[]]},{"id":"fdfe2841c19b643f","type":"api-call-service","z":"fcdd7ca7c451f869","name":"Text Kim","server":"24905bcc.e675d4","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_ikim","areaId":[],"deviceId":[],"entityId":[],"data":"{\"title\":\"Leak Detected!!\",\"message\":\"Device {{topic}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":420,"wires":[[]]},{"id":"7df1a157d5db4da2","type":"api-call-service","z":"fcdd7ca7c451f869","name":"Flash Lights","server":"24905bcc.e675d4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["b10645b4ac14c733a2514f252c06f754","350f902e111a0923bf43de08097d61ad"],"entityId":[],"data":"{\t    \"color_name\": \"red\",\t    \"flash\": \"long\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":670,"y":340,"wires":[[]]},{"id":"06fb564716b71589","type":"api-call-service","z":"fcdd7ca7c451f869","name":"Announcement","server":"24905bcc.e675d4","version":5,"debugenabled":false,"domain":"tts","service":"cloud_say","areaId":[],"deviceId":[],"entityId":["media_player.front_room","media_player.gym","media_player.living_room","media_player.workshop"],"data":"{\"message\":\"Alert. Leak Detected!\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":460,"wires":[[]]},{"id":"24905bcc.e675d4","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]

The second flow is designed to keep a constant eye on the leak sensors to make sure they are all functioning. It polls the state of the leak sensors every 24 hours and then counts how many are OK (off), Wet (On) or have dropped off the Zigbee network and unavailable. It uses a counter add up how many of the sensors are in each state and then uses a template node to format an email based upon the results of the states.

[{"id":"6a78e421fb764194","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":1760,"y":740,"wires":[]},{"id":"60ef2d2396b9ee0c","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count \\n Unavailable","x":470,"y":680,"wires":[["13ef706bba17cb91"]]},{"id":"b9ae9d775a272ea3","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Addition Bath Sink","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_addition_bath_sink_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":480,"wires":[["6c236d92a0c75a2c"]]},{"id":"10e42f1ef3823764","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Addition Bath Toilet","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_addition_bath_toilet_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":520,"wires":[["6c236d92a0c75a2c"]]},{"id":"7196cd4a320f5e95","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Addition Kitchen Sink","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_addition_sink_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":100,"y":560,"wires":[["6c236d92a0c75a2c"]]},{"id":"bec33154e2a97fb6","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Garage Util","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_garage_utility_closet_moisture_2","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":600,"wires":[["6c236d92a0c75a2c"]]},{"id":"b0de2d281e09a89f","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Guest Bath Sink","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_guestbath_sink_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":640,"wires":[["6c236d92a0c75a2c"]]},{"id":"592c9d1d1a02ccd1","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Guest BathToilet","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.lumi_lumi_sensor_wleak_aq1_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":80,"y":680,"wires":[["6c236d92a0c75a2c"]]},{"id":"b6149260daf9bf1e","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Kitchen Refer","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.leak_kitchen_refer_moisture_2","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":720,"wires":[["6c236d92a0c75a2c"]]},{"id":"860ae124d9767a3c","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Kitchen Sink","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_kitchen_sink_moisture_2","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":760,"wires":[["6c236d92a0c75a2c"]]},{"id":"7374abe699a61b34","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Laundry","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_guestbath_toilet_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":60,"y":800,"wires":[["6c236d92a0c75a2c"]]},{"id":"3ce67fac845c5fcb","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Master Bath Sink (R)","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_master_bath_sink_right_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":840,"wires":[["6c236d92a0c75a2c"]]},{"id":"8e5ac31b55c5d5b8","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Master Bath Sink (L)","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_master_bath_sink_left_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":880,"wires":[["6c236d92a0c75a2c"]]},{"id":"7053e5db1798a521","type":"poll-state","z":"1db7b5df0bcd43ea","name":"Master Bath Toilet","server":"24905bcc.e675d4","version":3,"exposeAsEntityConfig":"","updateInterval":"24","updateIntervalType":"num","updateIntervalUnits":"hours","outputInitially":false,"outputOnChanged":false,"entityId":"binary_sensor.sensor_leak_master_bath_toilet_moisture","stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputs":1,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":920,"wires":[["6c236d92a0c75a2c"]]},{"id":"6c236d92a0c75a2c","type":"switch","z":"1db7b5df0bcd43ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"unavailable","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":290,"y":660,"wires":[["60ef2d2396b9ee0c"],["3f9f3d6e72664063"],["9f556887aa96e89f"]]},{"id":"3f9f3d6e72664063","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count OK","x":460,"y":620,"wires":[["14a16900eaa47985"]]},{"id":"9f556887aa96e89f","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count Wet","x":470,"y":740,"wires":[["0e775dc9c161d942"]]},{"id":"78bfa92ed1829389","type":"change","z":"1db7b5df0bcd43ea","name":"UNAVAILBLE","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"unavailable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":680,"wires":[["469b91b62cd772bc"]]},{"id":"6f25840aa1e598a8","type":"change","z":"1db7b5df0bcd43ea","name":"OK","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"ok","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":620,"wires":[["469b91b62cd772bc"]]},{"id":"648eeea417d9c01a","type":"change","z":"1db7b5df0bcd43ea","name":"LEAK","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"leak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":740,"wires":[["469b91b62cd772bc"]]},{"id":"13ef706bba17cb91","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":680,"wires":[["78bfa92ed1829389"]]},{"id":"14a16900eaa47985","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":620,"wires":[["6f25840aa1e598a8"]]},{"id":"0e775dc9c161d942","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":740,"wires":[["648eeea417d9c01a"]]},{"id":"0c9388b9110228d1","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: ALERT","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status Email *ALERT*","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1380,"y":740,"wires":[["d4ee6874c5e4bb67"]]},{"id":"d4ee6874c5e4bb67","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"LEAKS DETECTED!!\n\nOK: {{payload.ok}}\nUnavailable: {{payload.unavailable}} !\nWET: {{payload.leak}} !!","output":"str","x":1610,"y":740,"wires":[["6a78e421fb764194"]]},{"id":"469b91b62cd772bc","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":990,"y":680,"wires":[["a09422fd8721c8c0"]]},{"id":"a09422fd8721c8c0","type":"switch","z":"1db7b5df0bcd43ea","name":"Any Leaks?","property":"payload.leak","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":680,"wires":[["8378548b78b1d602"],["0c9388b9110228d1"]]},{"id":"92c51e2313963583","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: WARNING","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status WARNING","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1391,"y":643,"wires":[["0ea348a86f1935eb"]]},{"id":"72171757f6984c71","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":1741,"y":643,"wires":[]},{"id":"0ea348a86f1935eb","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Great news, there are no leaks, but there are offline sensors.\n\nOK: {{payload.ok}}\nUnavailable: {{payload.unavailable}}","output":"str","x":1601,"y":643,"wires":[["72171757f6984c71"]]},{"id":"37605c20780b86c5","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":1740,"y":580,"wires":[]},{"id":"b552337e8fea95d0","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Great news, there are no leaks or unavalable sensors.\n\n{{payload.ok}} Sensors Reporting OK","output":"str","x":1600,"y":580,"wires":[["37605c20780b86c5"]]},{"id":"8016c1588154e72b","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: OK","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status OK","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1370,"y":580,"wires":[["b552337e8fea95d0"]]},{"id":"8378548b78b1d602","type":"switch","z":"1db7b5df0bcd43ea","name":"Any Unavail?","property":"payload.unavailable","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":1170,"y":620,"wires":[["8016c1588154e72b"],["92c51e2313963583"]]},{"id":"302b956af61b6799","type":"comment","z":"1db7b5df0bcd43ea","name":"Poll all sensors every 24 hours and count how many are OK, unavailable, or wet. \\n Customize emailed alert depending on scenario (OK, WARNING, ALARM)","info":"","x":600,"y":500,"wires":[]},{"id":"24905bcc.e675d4","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]

I like it!

I always forget that you can have multiple entities listed in one events:state node. I’ll be going back and combining all of my individual nodes for each leak sensor, door, etc into one like you’ve done so it doesn’t take as much real estate.

I’m doing something similar but instead of using the topic, which I believe is the entity_id:

{
    "title": "Leak Detected!!",
    "message": "Device {{topic}}"
}

I’m using the following to get the friendly name:

{
    "data": {
        "push": {
            "sound": "News_Flash.caf"
        }
    },
    "title": "Home Assistant Alert!",
    "message": "Leak detected at {{data.new_state.attributes.friendly_name}}"
}
1 Like

Update: I discovered a glitch in the logic of the status reporting flow. The counter is not being reset every time the flow runs with the poll-state so the number of sensors being reported is incrementing above the number of actual sensors. So I’ve added a change node to the end that sends a msg to the counters with the topic “resetCounter”. I then had to add a switch node after the counters that ignores the msg to reset the counter so that it does not trigger the flow.

I also wanted more control over the time when the flow runs so I added an eztimer node and switched from poll-state to current-state to gain the input needed for the timer.

All new logic appears to be functioning as expected.

[{"id":"6a78e421fb764194","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":2160,"y":760,"wires":[]},{"id":"60ef2d2396b9ee0c","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count \\n Unavailable","x":710,"y":700,"wires":[["effb15775d44d347"]]},{"id":"6c236d92a0c75a2c","type":"switch","z":"1db7b5df0bcd43ea","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"unavailable","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":530,"y":680,"wires":[["60ef2d2396b9ee0c"],["3f9f3d6e72664063"],["9f556887aa96e89f"]]},{"id":"3f9f3d6e72664063","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count OK","x":700,"y":640,"wires":[["33c588ca3d0336dd"]]},{"id":"9f556887aa96e89f","type":"msg-counter","z":"1db7b5df0bcd43ea","name":"Count Wet","x":710,"y":760,"wires":[["2ac52c8811f128bb"]]},{"id":"78bfa92ed1829389","type":"change","z":"1db7b5df0bcd43ea","name":"UNAVAILBLE","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"unavailable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":700,"wires":[["469b91b62cd772bc"]]},{"id":"6f25840aa1e598a8","type":"change","z":"1db7b5df0bcd43ea","name":"OK","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"ok","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":640,"wires":[["469b91b62cd772bc"]]},{"id":"648eeea417d9c01a","type":"change","z":"1db7b5df0bcd43ea","name":"LEAK","rules":[{"t":"set","p":"payload","pt":"msg","to":"count","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"leak","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":760,"wires":[["469b91b62cd772bc"]]},{"id":"13ef706bba17cb91","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1030,"y":700,"wires":[["78bfa92ed1829389"]]},{"id":"14a16900eaa47985","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1030,"y":640,"wires":[["6f25840aa1e598a8"]]},{"id":"0e775dc9c161d942","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1030,"y":760,"wires":[["648eeea417d9c01a"]]},{"id":"0c9388b9110228d1","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: ALERT","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status Email *ALERT*","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1780,"y":760,"wires":[["d4ee6874c5e4bb67"]]},{"id":"d4ee6874c5e4bb67","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"LEAKS DETECTED!!\n\nOK: {{payload.ok}}\nUnavailable: {{payload.unavailable}} !\nWET: {{payload.leak}} !!","output":"str","x":2010,"y":760,"wires":[["6a78e421fb764194","7b6b8b6b0df0f981"]]},{"id":"469b91b62cd772bc","type":"join","z":"1db7b5df0bcd43ea","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1370,"y":700,"wires":[["a09422fd8721c8c0"]]},{"id":"a09422fd8721c8c0","type":"switch","z":"1db7b5df0bcd43ea","name":"Any Leaks?","property":"payload.leak","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":1530,"y":700,"wires":[["8378548b78b1d602"],["0c9388b9110228d1"]]},{"id":"92c51e2313963583","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: WARNING","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status WARNING","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1791,"y":663,"wires":[["0ea348a86f1935eb"]]},{"id":"72171757f6984c71","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":2141,"y":663,"wires":[]},{"id":"0ea348a86f1935eb","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Great news, there are no leaks, but there are offline sensors.\n\nOK: {{payload.ok}}\nUnavailable: {{payload.unavailable}}","output":"str","x":2001,"y":663,"wires":[["72171757f6984c71","7b6b8b6b0df0f981"]]},{"id":"37605c20780b86c5","type":"e-mail","z":"1db7b5df0bcd43ea","server":"smtp.gmail.com","port":"465","authtype":"BASIC","saslformat":true,"token":"oauth2Response.access_token","secure":true,"tls":true,"name":"[email protected]","dname":"Email","x":2140,"y":600,"wires":[]},{"id":"b552337e8fea95d0","type":"template","z":"1db7b5df0bcd43ea","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Great news, there are no leaks or unavalable sensors.\n\n{{payload.ok}} Sensors Reporting OK","output":"str","x":2000,"y":600,"wires":[["37605c20780b86c5","7b6b8b6b0df0f981"]]},{"id":"8016c1588154e72b","type":"change","z":"1db7b5df0bcd43ea","name":"Email Subject: OK","rules":[{"t":"set","p":"topic","pt":"msg","to":"Daily Leak Status OK","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1770,"y":600,"wires":[["b552337e8fea95d0"]]},{"id":"8378548b78b1d602","type":"switch","z":"1db7b5df0bcd43ea","name":"Any Unavail?","property":"payload.unavailable","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":1550,"y":640,"wires":[["8016c1588154e72b"],["92c51e2313963583"]]},{"id":"302b956af61b6799","type":"comment","z":"1db7b5df0bcd43ea","name":"Poll all sensors at 6am daily and count how many are OK, unavailable, or wet. \\n Customize emailed alert depending on scenario (OK, WARNING, ALARM)","info":"","x":790,"y":520,"wires":[]},{"id":"7b6b8b6b0df0f981","type":"change","z":"1db7b5df0bcd43ea","name":"Reset Counter","rules":[{"t":"set","p":"topic","pt":"msg","to":"resetCounter","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":560,"wires":[["3f9f3d6e72664063","60ef2d2396b9ee0c","9f556887aa96e89f"]]},{"id":"33c588ca3d0336dd","type":"switch","z":"1db7b5df0bcd43ea","name":"Ignore Reset","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"resetCounter","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":640,"wires":[["14a16900eaa47985"]]},{"id":"effb15775d44d347","type":"switch","z":"1db7b5df0bcd43ea","name":"Ignore Reset","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"resetCounter","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":700,"wires":[["13ef706bba17cb91"]]},{"id":"2ac52c8811f128bb","type":"switch","z":"1db7b5df0bcd43ea","name":"Ignore Reset","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"resetCounter","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":760,"wires":[["0e775dc9c161d942"]]},{"id":"85271e043ca4347c","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Addition Bath Sink","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_addition_bath_sink_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":460,"wires":[["6c236d92a0c75a2c"]]},{"id":"1298df8481a210ab","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Addition Bath Toilet","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_addition_bath_toilet_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":500,"wires":[["6c236d92a0c75a2c"]]},{"id":"6cca12d47950e4fd","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Addition Kitchenette Sink","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_addition_sink_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":310,"y":540,"wires":[["6c236d92a0c75a2c"]]},{"id":"13bfb9aaa45690d2","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Garage Util Closet","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_garage_utility_closet_moisture_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":580,"wires":[["6c236d92a0c75a2c"]]},{"id":"f3b31194881cf6fd","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Guest Bath Sink","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_guestbath_sink_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":280,"y":620,"wires":[["6c236d92a0c75a2c"]]},{"id":"96f6a945cbdd538b","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Guest Bath Toilet","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.lumi_lumi_sensor_wleak_aq1_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":660,"wires":[["6c236d92a0c75a2c"]]},{"id":"39cbc78bd987adcd","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Kitchen Refer","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.leak_kitchen_refer_moisture_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":280,"y":700,"wires":[["6c236d92a0c75a2c"]]},{"id":"81c4aaa36cd87f36","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Kitchen Sink","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_kitchen_sink_moisture_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":270,"y":740,"wires":[["6c236d92a0c75a2c"]]},{"id":"0190a315367b4eae","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Laundry","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_guestbath_toilet_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":260,"y":780,"wires":[["6c236d92a0c75a2c"]]},{"id":"16d4a1676eb6b5b8","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Master Bath Sink (R)","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_master_bath_sink_right_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":300,"y":820,"wires":[["6c236d92a0c75a2c"]]},{"id":"21cee0d8f045fd94","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Master Bath Sink (L)","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_master_bath_sink_left_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":300,"y":860,"wires":[["6c236d92a0c75a2c"]]},{"id":"895f611fa6bb1971","type":"api-current-state","z":"1db7b5df0bcd43ea","name":"Master Bath Toilet","server":"24905bcc.e675d4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sensor_leak_master_bath_toilet_moisture","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":290,"y":900,"wires":[["6c236d92a0c75a2c"]]},{"id":"f02cc06e2d325a67","type":"eztimer","z":"1db7b5df0bcd43ea","name":"Timer","debug":false,"autoname":"06:00","tag":"eztimer","topic":"","suspended":false,"sendEventsOnSuspend":false,"latLongSource":"haZone","latLongHaZone":"zone.home","lat":"","lon":"","timerType":"2","startupMessage":false,"ontype":"2","ontimesun":"dawn","ontimetod":"06:00","onpropertytype":"msg","onproperty":"payload","onvaluetype":"num","onvalue":1,"onoffset":0,"onrandomoffset":0,"onsuppressrepeats":false,"offtype":"3","offtimesun":"dusk","offtimetod":"dusk","offduration":"00:00:01","offpropertytype":"msg","offproperty":"payload","offvaluetype":"num","offvalue":0,"offoffset":0,"offrandomoffset":0,"offsuppressrepeats":true,"resend":false,"resendInterval":"0s","mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":50,"y":680,"wires":[["85271e043ca4347c","1298df8481a210ab","13bfb9aaa45690d2","f3b31194881cf6fd","96f6a945cbdd538b","39cbc78bd987adcd","81c4aaa36cd87f36","0190a315367b4eae","16d4a1676eb6b5b8","21cee0d8f045fd94","895f611fa6bb1971","6cca12d47950e4fd"]]},{"id":"24905bcc.e675d4","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]