Skip to content

Instantly share code, notes, and snippets.

@Skydras
Forked from bbbenji/leak-detector-notifier.yaml
Last active February 23, 2026 20:50
Show Gist options
  • Select an option

  • Save Skydras/0b66e2aed6aa3eb8c09842d94a24ec16 to your computer and use it in GitHub Desktop.

Select an option

Save Skydras/0b66e2aed6aa3eb8c09842d94a24ec16 to your computer and use it in GitHub Desktop.
Automatically detects any moisture (leak) sensor in Home Assistant — no need to manually select sensors. Sends customizable mobile notifications with your own title and message. Optional features include auto-clear notifications when the sensor goes dry and repeating alarms until cleared.
blueprint:
name: Leak detection & notifier (Custom text + option to repeat alarm)
description: >
Sends notification when moisture is detected.
Optional auto-clear notification and repeating alarm until cleared.
domain: automation
input:
notify_device:
name: Notify device
selector:
device:
integration: mobile_app
notification_title:
name: Leak notification title
default: "⚠️💧 Leak detected!"
selector:
text:
notification_message:
name: Leak notification message
default: "🚨 {{ sensor_name }} has detected water!"
selector:
text:
clear_enabled:
name: Enable auto-clear notification
description: Send notification when sensor becomes dry
default: false
selector:
boolean:
clear_title:
name: Clear notification title
default: "✅ Leak cleared"
selector:
text:
clear_message:
name: Clear notification message
default: "✔️ {{ sensor_name }} is dry again."
selector:
text:
repeat_enabled:
name: Enable repeating alarm
description: Repeat notification until leak is cleared
default: false
selector:
boolean:
repeat_interval:
name: Repeat interval (minutes)
default: 5
selector:
number:
min: 1
max: 60
unit_of_measurement: minutes
mode: box
script_to_run:
name: Optional script to run
default: []
selector:
entity:
domain: script
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: >
{{ trigger.event.data.new_state is not none
and trigger.event.data.new_state.attributes.device_class == "moisture" }}
action:
- variables:
sensor_name: "{{ trigger.event.data.new_state.attributes.friendly_name }}"
new_state: "{{ trigger.event.data.new_state.state }}"
leak_title: !input notification_title
leak_message: !input notification_message
clear_title_var: !input clear_title
clear_message_var: !input clear_message
clear_enabled_var: !input clear_enabled
repeat_enabled_var: !input repeat_enabled
repeat_interval_var: !input repeat_interval
selected_script: !input script_to_run
- choose:
# =====================
# LEAK DETECTED
# =====================
- conditions:
- condition: template
value_template: "{{ new_state == 'on' }}"
sequence:
# Initial notification
- domain: mobile_app
type: notify
device_id: !input notify_device
title: "{{ leak_title }}"
message: "{{ leak_message }}"
data:
icon: "mdi:water-alert"
# Optional script
- choose:
- conditions:
- condition: template
value_template: "{{ selected_script != [] }}"
sequence:
- service: script.turn_on
target:
entity_id: "{{ selected_script }}"
# Optional repeating alarm
- choose:
- conditions:
- condition: template
value_template: "{{ repeat_enabled_var }}"
sequence:
- repeat:
while:
- condition: template
value_template: >
{{ is_state(trigger.event.data.entity_id, 'on') }}
sequence:
- delay:
minutes: "{{ repeat_interval_var }}"
- domain: mobile_app
type: notify
device_id: !input notify_device
title: "🔁 Reminder"
message: "{{ leak_message }}"
data:
icon: "mdi:water-alert"
# =====================
# LEAK CLEARED
# =====================
- conditions:
- condition: template
value_template: >
{{ new_state == 'off' and clear_enabled_var }}
sequence:
- domain: mobile_app
type: notify
device_id: !input notify_device
title: "{{ clear_title_var }}"
message: "{{ clear_message_var }}"
data:
icon: "mdi:water-check"
mode: restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment