-
-
Save bbbenji/d4d1fe1856ec54370a422508c8963f2a to your computer and use it in GitHub Desktop.
blueprint: | |
name: Leak detection & notifier | |
description: Send a notification when any configured moisture sensor becomes moist | |
domain: automation | |
input: | |
notify_device: | |
name: Notify device | |
description: "The device where the notification should be sent to." | |
selector: | |
device: | |
integration: mobile_app | |
trigger: | |
- event_data: {} | |
event_type: state_changed | |
platform: event | |
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: | |
domain: mobile_app | |
type: notify | |
device_id: !input notify_device | |
message: "{{ trigger.event.data.new_state.attributes.friendly_name }} has detected a leak." | |
title: "Leak detected!" | |
mode: single |
I installed this a long time ago, works great.
However noticed an error in my logs:
Also unsure if I automatically get updates to a blueprint AFTER an automation has been made?
Template variable error: 'None' has no attribute 'attributes' when rendering '{{ trigger.event.data.new_state.attributes.device_class == "moisture" }}'
09:57:21 – (ERROR) helpers/template.py
Is it possible to have the alert sent to more than one device - and a combination of iphones and alexas ?
I have tried to adapt in the yaml file, but when I test, no notifications are sent. I have checked the notification group I have set up, and this appears to work.
My config is as follows (not sure whether formatting works here):
blueprint:
name: Leak detection & notifier
description: Send a notification when any configured moisture sensor becomes moist
domain: automation
input:
notify_device:
name: Notify device
description: The device where the notification should be sent to.
selector:
device:
integration: mobile_app
multiple: false
source_url: https://gist.github.com/bbbenji/d4d1fe1856ec54370a422508c8963f2a
trigger:
- event_data: {}
event_type: state_changed
platform: event
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: notify.mobiles_plus_alexas
message: >-
{{ trigger.event.data.new_state.attributes.friendly_name }} has detected a leak.
title: Leak detected!
mode: single
life (and money) saver! Just trying to understand class hierarchy via haas documentation was rough. I do have a question. @bbbenji's code would trigger at every event to match against the AND conditions listed under condition. I'm rather unfamiliar with the trigger
framework (reading up on it) but would it be possible to only trigger when device_class == "moisture"
and then apply condition
of new_state.state == "on"
?
Thank you for this effort!
Very new to blueprints, I love this - but I want to be able to exclude a few leak sensors that I want to use for a different purpose. Any pointers on how I'd go about adding an exclude list? I see how to declare them here: https://gist.github.com/sbyx/1f6f434f0903b872b84c4302637d0890 but not sure how I'd eventually use that list.
Thanks for the blueprint!
I've forked it and modified, to make customizable actions. If someone interested, its here.