Water leak app notification in Home Assistant
Home Assistant is an extremely flexible home automation solution that does not come in a magic locked-down box. The flexibility comes with difficulty figuring out how to actually do things because of so many options and different approaches (just like with Linux overall).
I installed some Zigbee water leak sensors and needed a simple feature - notify me via the app when there is a leak. A quick Google search returned lots of results, forum posts, blueprints and no obvious solution so I decided to "click around" and find out how it can be done.
Setting up Home Assistant, TLS certificates, port forwarding and the mobile app is out of the scope of this post. I will only focus on the notification aspect. I bought Aqara water leak sensors (also known as Xiaomi SJCGQ11LM) and added them to Zigbee2MQTT. They were automatically detected by Home Assistant.
Setting up the notifications
- Go to Settings
- Select Automation and scenes
- Select Automations at the top
- Press CREATE AUTOMATION (bottom right blue button)
- Pick Start with an empty automation (don't use blueprints)
- Press ADD TRIGGER (button at the top)
- Select Device
- Find the name of you leak sensor (you assign it for example in Zigbee2MQTT during joining)
- The trigger field should automatically populate with name of your sensor and "becomes moist"
- Repeat ADD TRIGGER for all your sensors (you can always add or remove them later), all triggers are logically ORed
- Press ADD ACTION (button at the bottom)
- Pick Call service
- Press the three dots on the right next to the "Call service" row and select Edit in YAML
1 2 3 4
Finally, press SAVE (bottom right blue button) and put in the name (eg. "Leak start notification").
Done. You can also create an almost identical automation to notify when the sensors become dry. I was very positively surprised by the responsivness. The notifications are nearly instant, just 2-3 seconds after dipping a sensor in the water. They look just like every other iOS notifications. It may also make sense to add the leak sensors to a dashboard to view their state.