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}]