Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bskjon/c28c23564cdac8b4191f61cb51467837 to your computer and use it in GitHub Desktop.
Save bskjon/c28c23564cdac8b4191f61cb51467837 to your computer and use it in GitHub Desktop.
blueprint:
name: Vannlekasje
description: Varsel for vannlekasje
domain: automation
input:
water_sensor:
name: Lekasje sensor
description: Vannlekasje sensor
selector:
entity:
filter:
- device_class: moisture
multiple: true
devices:
name: Devices
description: Devices where notification should be sent
selector:
device:
integration: mobile_app
multiple: true
trigger:
- platform: state
entity_id: !input water_sensor
mode: single
action:
# Debug
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ trigger }}"
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ trigger.entity_id }}"
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ trigger.to_state }}"
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ trigger.to_state.state }}"
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ is_state(trigger.to_state.state, 'on') }}"
# - service: input_text.set_value
# data_template:
# entity_id: input_text.debug
# value: "{{ trigger.to_state.state == 'on' }}"
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input devices
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: "Vannlekasje!"
message: "Vannlekasje oppdaget! Kontroller sensor områder."
data:
tag: "water-leak-alert"
visibility: public
notification_icon: "mdi:home-flood"
color: "red"
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
message: "TTS"
data:
tag: "water-leak-alert-tts"
ttl: 0
priority: high
media_stream: alarm_stream_max
language: "no-NB"
tts_text: "Vannlekasje oppdaget. Kontroller sensor ommråder."
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input devices
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: "Vannlekasje avsluttet"
message: "Vannlekasjen er avsluttet, og sensorene er tørre."
data:
tag: "water-leak-alert"
visibility: public
notification_icon: "mdi:water-check"
color: "green"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'unavailable' }}"
- condition: template
value_template: "{{ trigger.to_state.state == 'unknown' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input devices
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: "Frakoblet lekasjesensor"
message: "En eller flere lekasjesensorer ble utilgjengelig. Vennligst sjekk at batteriet ikke har gått tomt, og at koordinerer ikke er frakoblet og at enheten er påskrudd og medlem av nettverket!"
data:
tag: "device-water-leak-detector-unavailable"
visibility: public
notification_icon: "mdi:water-off"
color: "gray"
default:
- alias: Send a notification to each device
repeat:
for_each: !input devices
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: "TEST - Vannlekasje"
message: "Test notifikasjon for vannlekasje"
data:
tag: "water-leak-alert-test"
visibility: public
notification_icon: "mdi:home-flood"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment