This uses a bunch of Abode water leak sensors (integrated via Abode + HomeKit) to alert on leaks with an actionable notification that then controls a z-wave shutoff valve for the water main.
The notification service is from GitHub - cadavre/iq_notify
alias: "!Leak Detector - Water Shutoff"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.water_heater_water_sensor
- binary_sensor.laundry_room_water_sensor
- binary_sensor.refrigerator_water_sensor
- binary_sensor.master_bathroom_toilet_water_sensor
- binary_sensor.basement_bathroom_toilet_water_sensor
- binary_sensor.upstairs_bathroom_toilet_water_sensor
to: "on"
condition: []
action:
- repeat:
until:
- condition: template
value_template: "{{ wait.trigger is not none or repeat.index >= off_delay }}"
sequence:
- alias: Prompt for water shutoff
service: notify.iq_notify_parents
data:
message: >-
{{trigger.from_state.name}} is WET! Turning off water in
{{(off_delay + 1) - repeat.index}} minutes
data:
group: water_leak
importance: high
channel: alarm_stream
tag: water_leak
ttl: 0
priority: high
actions:
- action: "{{ action_turn_off }}"
title: Turn Off Water
- action: "{{ action_ignore }}"
title: Ignore
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_turn_off }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_ignore }}"
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- alias: Perform the action
choose:
- conditions: "{{ not wait.trigger }}"
alias: "No Response: Turn Off Water"
sequence:
- service: notify.iq_notify_parents
data:
message: Turning Off Water after no response
- service: switch.turn_off
data: {}
target:
entity_id: switch.water_main_valve
enabled: true
- conditions: "{{ wait.trigger.event.data.action == action_turn_off }}"
alias: Turn Off Requested
sequence:
- service: notify.iq_notify_parents
data:
message: Turning Off Water Now
- service: switch.turn_off
data: {}
target:
entity_id: switch.water_main_valve
enabled: true
- conditions: "{{ wait.trigger.event.data.action == action_ignore }}"
alias: Ignore Requested
sequence:
- service: notify.iq_notify_parents
data:
message: Ignoring water alarm
variables:
action_turn_off: "{{ 'TURN_OFF_' ~ trigger.to_state.context.id }}"
action_ignore: "{{ 'IGNORE_' ~ trigger.to_state.context.id }}"
off_delay: 2
mode: single