I’d like to share a solution that I came up with for an automation. I was looking for a straight forward method to trigger an alarm and continuously play a TTS message on my Echo Pop whenever a water leak sensor was wet. I wanted the automation to continue until I cleared the wet state of the sensor. I wanted one automation that would work for multiple sensors, in different areas and I wanted the Echo to announce which area the leak was detected. I found multiple ways online to accomplish this i.e. the Alert integration, but I’m new to HA and to writing automations and I wasn’t comfortable using that method because it required editing the configuration.yaml file. What I came up with meets all my needs and was easy for me to configure using the UI. I’m sharing it in case someone else is looking for a similar solution.
The automation is triggered by one of four different sensors (I’m using Sonoff leak sensors) placed in different areas. If any one of them detects water a siren sounds. I’m just using a Reolink camera that I have that has a siren function but if anyone knows of a good zigbee or zwave siren/alarm please suggest it. I’m then using the choose to determine which sensor triggered by using the trigger ID. Each option then plays a TTS message (different message for each area) waits 7 seconds and then repeats. It will repeat the message until the sensor is dry. Once dry the automation continues down through and turns off the siren.
I’m not sure if there is another way to share the automation other than just pasting the yaml here. If there’s a better way please let me know. I’m sure there is probably a more elegant way to solve this problem but this method was in my wheelhouse and it works. I’m trying to learn so I’m open to better methods if you want to share.
alias: Leak Detectors
description: ""
triggers:
- type: moist
device_id: 1eae889d136536088eb9151084d40ce8
entity_id: cd4b083c39dd8d204abfad18b11ca6a9
domain: binary_sensor
trigger: device
id: utility tub
- type: moist
device_id: 78512da1c640ffc8251469f0ebdd5307
entity_id: fb4dd2364ff3fc53d118f4ecf1d9c8b4
domain: binary_sensor
trigger: device
id: water heater
- type: moist
device_id: 358543251a7f86521099ddd4d3fa1100
entity_id: e4eb6e5f0bfe488363be5a97a51bee89
domain: binary_sensor
trigger: device
id: laundry room
- type: moist
device_id: 5e58a748c3389ffbd88d5f5ed46ae2c7
entity_id: dc67baffdc56d536a927025eacdec100
domain: binary_sensor
trigger: device
id: kitchen sink
conditions: []
actions:
- action: siren.turn_on
metadata: {}
data: {}
target:
entity_id: siren.reolink_1_siren
enabled: true
- choose:
- conditions:
- condition: trigger
id:
- utility tub
sequence:
- repeat:
until:
- type: is_not_moist
condition: device
device_id: 1eae889d136536088eb9151084d40ce8
entity_id: cd4b083c39dd8d204abfad18b11ca6a9
domain: binary_sensor
sequence:
- action: notify.alexa_media_echo_pop
metadata: {}
data:
message: leak detected, utility tub area
- delay:
hours: 0
minutes: 0
seconds: 7
milliseconds: 0
- conditions:
- condition: trigger
id:
- water heater
sequence:
- repeat:
until:
- type: is_not_moist
condition: device
device_id: 78512da1c640ffc8251469f0ebdd5307
entity_id: fb4dd2364ff3fc53d118f4ecf1d9c8b4
domain: binary_sensor
sequence:
- action: notify.alexa_media_echo_pop
metadata: {}
data:
message: leak detected, water heater area
- delay:
hours: 0
minutes: 0
seconds: 7
milliseconds: 0
- conditions:
- condition: trigger
id:
- laundry room
sequence:
- repeat:
until:
- type: is_not_moist
condition: device
device_id: 358543251a7f86521099ddd4d3fa1100
entity_id: e4eb6e5f0bfe488363be5a97a51bee89
domain: binary_sensor
sequence:
- action: notify.alexa_media_echo_pop
metadata: {}
data:
message: leak detected, laundry room
- delay:
hours: 0
minutes: 0
seconds: 7
milliseconds: 0
- conditions:
- condition: trigger
id:
- kitchen sink
sequence:
- repeat:
until:
- type: is_not_moist
condition: device
device_id: 5e58a748c3389ffbd88d5f5ed46ae2c7
entity_id: dc67baffdc56d536a927025eacdec100
domain: binary_sensor
sequence:
- action: notify.alexa_media_echo_pop
metadata: {}
data:
message: leak detected, kitchen sink area
- delay:
hours: 0
minutes: 0
seconds: 7
milliseconds: 0
- action: siren.turn_off
metadata: {}
data: {}
target:
entity_id: siren.reolink_1_siren
mode: single