Water leak notification & auto shutoff

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
1 Like

I have a much simpler automation, but this is cool, I want to give it a try. A few questions.

What is the input boolean for? I don’t see it referenced elsewhere?
What is service: notify.iq

The input boolean was from me forgetting to remove it from testing. My water sensors are LOUD so I really don’t like testing with them vs just a boolean helper.

iq_notify is: GitHub - cadavre/iq_notify which I use for all my notifications. Lets me do all sorts of easy conditional notifications AND if someone changes devices I can just go change the one iq_notify config vs all my automations.

@EricD183 Thank you for this automation. I am using a simple one as well. However, I would like to implement yours and have a few questions:
1- What is in water_group and it s function?
2- Can I use the Home assistant notification instead of the cadavre/iq_notify since I already have a notify.yaml with groups on it?
Thank you.

Not sure what you mean by water_group

Yes you can use any notification service

Thank you Eric. I am attaching a screen shot of your code with what I meant.
image

1 Like