This is an example of how to get the auto water valve I purchased of Amazon.com to automatically shut off the water in the event of a detected leak. I will be adding the full process to this post in the next few weeks. This is just a placeholder until I do complete this Howto.
The Automation
Full Yaml File
alias: _MainWaterOffWhenLeakDetected
description: ""
trigger:
- type: moist
platform: device
device_id: 2d5f68e651c6b32c9a71fc3f1da48ae0
entity_id: dc8581dea015c39f281d693f4a0d8f7d
domain: binary_sensor
id: When Main Water Detected Water
- platform: event
event_type: timer.finished
event_data:
event id: timer.attemptwaterturnon
id: When Attempt Water Turn On Done
- type: not_moist
platform: device
device_id: 2d5f68e651c6b32c9a71fc3f1da48ae0
entity_id: dc8581dea015c39f281d693f4a0d8f7d
domain: binary_sensor
id: When Main Water Became Dry
- device_id: 1940ec1fe051d5b132268a98584ebce3
domain: zha
platform: device
type: device_offline
subtype: device_offline
id: Main Water Valve turned on or off
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- When Main Water Detected Water
sequence:
- if:
- condition: device
type: is_on
device_id: 1940ec1fe051d5b132268a98584ebce3
entity_id: 0f8e6f9d665fc5b0565077bd4116128b
domain: light
then:
- type: turn_off
device_id: 1940ec1fe051d5b132268a98584ebce3
entity_id: 0f8e6f9d665fc5b0565077bd4116128b
domain: light
- service: timer.start
data:
duration: "1200"
target:
entity_id: timer.attemptwaterturnon
- service: notify.ha_email
data:
message: Main leak detector has detected a leak.
title: Main Leak Detector Triggered!!!
- service: notify.ecobee
data:
message: Main water detector has detected a wet condition.
title: Main water detected wet condition...
target: 0
- service: media_player.play_media
target:
entity_id: media_player.m5stack_atom_echo_889034_m5stack_atom_echo_889034
data:
media_content_id: >-
media-source://tts/tts.piper?message=Water+main+off+due+to+detected+leak%21&language=en_US&voice=en_US-lessac-low
media_content_type: provider
metadata:
title: Water main off due to detected leak!
thumbnail: https://brands.home-assistant.io/_/tts/logo.png
media_class: app
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://tts
- media_content_type: provider
media_content_id: >-
media-source://tts/tts.piper?message=Water+main+off+due+to+detected+leak%21&language=en_US&voice=en_US-lessac-low
- conditions:
- condition: trigger
id:
- When Attempt Water Turn On Done
sequence:
- if:
- type: is_moist
condition: device
device_id: 2d5f68e651c6b32c9a71fc3f1da48ae0
entity_id: dc8581dea015c39f281d693f4a0d8f7d
domain: binary_sensor
then:
- service: timer.start
data:
duration: "1200"
target:
entity_id: timer.attemptwaterturnon
- service: notify.ha_email
data:
message: Main water detector has detected a wet condition.
title: Main water detected wet condition...
- service: notify.ecobee
data:
message: Main leak detector is wet!!!
title: Main leak detector is triggered!!!
target: 0
else:
- service: notify.ha_email
data:
message: Main water detector is no longer wet
title: Main water detector is good.
- service: notify.ecobee
data:
message: Main leak detector is clear!!!
title: "Main leak detector is good!! "
target: 0
mode: single