Water leakage notification blueprint

I have other automations where I can select the notify group.
Does anyone know what I should change mobile_app to? in order to make this possible

Please share the blueprint and I can take a look.

I haven’t had time to work on this but now I want to use the alert integration to notify and confirm. This way the alert will continue and until you go and acknowledge it or the conditions change

I posted a comment on your GitHub but wanted to make one here too for anyone running into a problem like I did. I was not getting any notifications for leaks and looked at the yaml and was getting an error. I needed to remove the !input from the actions to relieve the error and can confirm it fires off as expected.

was:

action:
domain: mobile_app
type: notify
device_id: !input notify_device

Now:

action:
domain: mobile_app
type: notify
device_id: notify_device

Hope this helps someone.

Thanks for the typo fix @LCSteve!

As for the !input error you’re are getting, I have no idea why… It’s a valid tag and required for it to be configurable. See: Blueprint tutorial - Home Assistant

I found this, and the configuration where you use just one blueprint / automation for all sensors are genious.
One thing bugs me a bit, though:
This automation uses the friendly name of the entity that is triggered, in this case the water leak entity.
If I don’t set a new friendly name for that entity, it gives me messages like this: “Testsensor water leak has detected a leak”, which seems a bit strange to me.
Isn’t it possible to change the action in the automation to use the device friendly name instead?

See this picture:

Can that be done? And if so, how?

Thanks

I am not sure that’s possible without making the blueprint overly complicated. Keep in mind that it’s listening to moisture entities, not their devices. Just change the entity’s friendly name. As an example, I use “Kitchen flood sensor” so my notification would show “Kitchen flood sensor has detected a leak.”

Yes, that’s what I ended up doing. Thanks for the blueprint, nice work!

1 Like

Let me start this by saying that I’m in no way a HA automation expert. It seems that this automation triggers every time ANY state changes, and the evaluates the condition as to whether the event has a device class of moisture. Probably 99% of the times this automation triggers, it immediately exits out as the state change was something other than moisture. Is there any way to limit the automation to only trigger on state changes of moisture sensors instead of all state changes?

5 Likes

Hi @benji,

I’ve been using this blueprint for a few weeks now and I never would’ve gotten this far without you, so thanks.

I migrated from Hubitat and they had a built in feature for this as well as some smart subsequent automations. I’m not here to tell anybody that this needs to be changed, but here’s some things that’ve helped me on another platform and I altered your blueprint to fit my needs (which might be useful to others).

Basic operation:
Detects the state change of moisture type sensors to on
Turn off DND on all voice assistants to prep for the announcements in case it’s at night
Turn off water supply valve (this is the part that was built into hubitat and what I am suggesting)
The water supply valve has it’s own independent automations that notify the house and devices if it is ever closed.
Activate a scene that turns all accent lights in the house blue
Notify phones with the dynamic announcement including leak sensor name
Announce via voice assistants including leak sensor name
By this time, the water supply valve would be closed and another message would’ve went to phones/voice assistant indicating the threat has been neutralized by turning off the water (in case I am unable to witness the messages in real time, the phones will still say where the leak was and that the water supply valve was closed).

This of course could all be in one automation and that’s where I was headed with this but then I decided at the last minute, I want to be notified of a water supply valve closure in all circumstances (not just leaks) so I left it separate for my circumstance.

Now that the lights are blue, I know where the leak is, and the water has been turned off, what do I do? I tied the lights reset automation back to the water supply valve being opened. Reason being, a leak sensor could stop being wet but the issue not yet resolved (because the water is still off or perhaps the leak is unresolved). The resetting of all the lights was cumbersome in Hubitat but I have adaptive lighting in HA, so I just automate a toggle on the adaptive lights and it puts everything back to how it should be. I guess this would be different for the user; a scene could be used for this too.

  mode: single
- id: '1642307791979'
  alias: Leak Detection - Notifier and Shutdown
  description: ''
  trigger:
  - platform: event
    event_type: state_changed
    event_data: {}
  condition:
  - condition: template
    value_template: '{{ trigger.event.data.new_state.attributes.device_class == "moisture"
      }}'
  - condition: template
    value_template: '{{ trigger.event.data.new_state.state == "on" }}'
  action:
  - service: script.alexa_disable_do_not_disturb_all_devices
  - type: turn_off
    device_id: dfd03c8879f516f34824e0ade307bdf8
    entity_id: switch.water_supply_valve
    domain: switch
  - service: scene.turn_on
    target:
      entity_id: scene.leak_detection_scene
  - service: notify.mobile_app_sarge_s_phone
    data:
      message: '{{ trigger.event.data.new_state.attributes.friendly_name }} has detected
        a leak.'
  - service: notify.mobile_app_iphone
    data:
      message: '{{ trigger.event.data.new_state.attributes.friendly_name }} has detected
        a leak.'
  - service: notify.alexa_media
    data:
      target: media_player.kitchen_echo_show, media_player.2nd_floor_hallway_echo_dot,media_player.bathroom_1_echo_dot,
        media_player.bedroom_2_echo_show,media_player.bedroom_echo_show, media_player.office_echo_show,media_player.garage_entryway_echo_show,
        media_player.garage_echo_dot
      data:
        type: announce
      message: '{{ trigger.event.data.new_state.attributes.friendly_name }} has detected
        a leak.'
  mode: single

These are merely fun suggestions that I’ve used in my personal setup and you can decide to incorporate them or not. Again, I want to thank you for the foundational legwork that made this easy for me to do.

3 Likes

Is there a performance implication to this triggering for all event changes?

Is there a way to narrow the trigger to event changes for moisture prior to the conditions?

1 Like

Looks like I changed this back to an automation:

alias: Leak Detection - Notifier and Shutdown
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.2nd_floor_bathroom_sink_leak_sensor
      - binary_sensor.bathroom_1_left_sink_leak_sensor
      - binary_sensor.bathroom_1_toilet_leak_sensor
      - binary_sensor.bathroom_2_left_sink_leak_sensor
      - binary_sensor.bathroom_2_toilet_leak_sensor
      - binary_sensor.dishwasher_leak_sensor
      - binary_sensor.downstairs_bathroom_toilet_leak_sensor
      - binary_sensor.kitchen_refrigerator_leak_sensor
      - binary_sensor.kitchen_sink_leak_sensor
      - binary_sensor.downstairs_bathroom_sink_leak_sensor
      - binary_sensor.water_heater_leak_sensor
      - binary_sensor.laundry_room_leak_sensor
      - binary_sensor.bathroom_2_right_sink_leak_sensor
      - binary_sensor.bathroom_1_right_sink_leak_sensor
      - binary_sensor.2nd_floor_bathroom_toilet_leak_sensor
    to: "on"
    from: "off"
condition: []
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.do_not_disturb
  - type: turn_off
    device_id: dfd03c8879f516f34824e0ade307bdf8
    entity_id: switch.water_supply_valve
    domain: switch
  - service: script.accent_lights_blue_alert
    data: {}
  - service: notify.notify
    data:
      message: "{{ trigger.to_state.name }} has detected a leak."
  - service: notify.alexa_media
    data:
      target: >-
        media_player.kitchen_echo_show,
        media_player.2nd_floor_hallway_echo_dot,media_player.bathroom_1_echo_dot,
        media_player.bedroom_2_echo_show,media_player.bedroom_echo_show,
        media_player.office_echo_show,media_player.garage_entryway_echo_show,
        media_player.garage_echo_dot, media_player.media_room_sonos_alexa
      data:
        type: announce
      message: "{{ trigger.to_state.name }} has detected a leak."
mode: single

no performance issues. Fires every time and immediately. Has saved me nearly a dozen times.

4 Likes

Could you please share the script for “script.accent_lights_blue_alert”? Thank you!

Sure but it doesn’t really help you unless you have TPLink KL430’s:

It makes all the light strips in the house do the nightrider effect but with blue.

alias: Accent Lights - Blue Alert
sequence:
  - service: tplink.sequence_effect
    target:
      entity_id:
        - light.kitchen_over_cabinet_1_leds
        - light.kitchen_over_cabinet_2_leds
        - light.kitchen_under_cabinet_1_leds
        - light.kitchen_under_cabinet_2_leds
        - light.big_tv_leds
        - light.living_room_end_table_1_leds
        - light.living_room_end_table_2_leds
        - light.living_room_end_table_3_leds
        - light.living_room_end_table_4_leds
        - light.bar_leds
        - light.buffet_leds
        - light.bedroom_bed_leds
        - light.bedroom_bureau_leds
        - light.bedroom_dresser_leds
        - light.bedroom_nightstand_1_leds
        - light.bedroom_nightstand_2_leds
        - light.bedroom_2_bed_leds
        - light.bedroom_2_dresser_leds
        - light.bedroom_2_leds
        - light.bedroom_2_nightstand_1_leds
        - light.bedroom_2_nightstand_2_leds
        - light.office_desk_leds
        - light.office_leds
        - light.bathroom_2_leds
        - light.bathroom_1_leds
        - light.media_room_leds
        - light.media_room_table_leds
        - light.downstairs_bathroom_leds
        - light.front_entryway_hall_tree_1_leds
        - light.front_entryway_hall_tree_2_leds
        - light.bubble_wall_light
        - light.media_room_fireplace_leds
        - light.sky_butthole
        - light.downstairs_media_leds
        - light.downstairs_tv_leds
        - light.garage_entryway_leds
        - light.under_island_leds
        - light.under_counter_leds
    data:
      sequence:
        - - 240
          - 100
          - 25
        - - 0
          - 0
          - 0
        - - 0
          - 0
          - 0
        - - 240
          - 100
          - 25
      brightness: 25
      transition: 1
      spread: 13
      direction: 1
mode: single
icon: mdi:alarm-light

1 Like

Thank you very much!

This is great! Thank you so much for sharing this. I can’t contribute to this other than to say I appreciate the chuckle from the light named “sky butthole”. :rofl:

When you have upwards of 200 lights, you have to start getting creative so alexa doesn’t confuse them. I present to you, the sky butthole:

1 Like

I built a node-red leak detection and notification automation. It has a 5 min back-off on notifications

1 Like

Thanks for this automation! I only just barely got my first water sensors and still need a valve, but I’m hoping to have a similar setup as yours soon. One thing I changed for my uses was switching the notify.notify section for my iPhone to get a critical alert, as demonstrated below, which alerts even when focus (such as DND or sleep) is on.

  - service: notify.mobile_app_iPhone
    data:
      title: Water Leak Detected!
      message: "{{ trigger.to_state.name }} has detected a leak."
      data:
        push:
          sound:
            name: default
            critical: 1
            volume: 1
2 Likes

Thank you. I had an android when I built it but recently switched to Apple. I’ll make the switch on my end.

I haven’t learned all the stuff with Apple critical alerts yet.