I have a few water leakage sensor around my home and I want to create a blueprint to trigger when the sensor turns “wet” and not have to create an automation for each one. The device_class is moisture and it is a binary_sensor. How can I create that ?
here
yes you see wet/dry
but it on/off
#=======================================================================
#
#=======================================================================
- id: Water Alarm
alias: 'Water Alarm'
trigger:
- entity_id: binary_sensor.water_leak
platform: state
to: 'on'
action:
- data:
entity_id: script.flash_garage_lights
service: script.turn_on
I am able to create an automation but I have to do it one by one so am looking for a blueprint that will use this device class and hence applies on all water leak sensors
but why create so many
trigger:
- entity_id:
- binary_sensor.leak1
- binary_sensor.leak2
- binary_sensor.leak3
- binary_sensor.leak4
- binary_sensor.leak5
- binary_sensor.leak6
- binary_sensor.leak7
platform: state
to: 'on'
action:
- data_template:
title: "Home Assistant"
message: "{{ trigger.to_state.attributes.friendly_name }} is leaking"
service: notify.notify
spacing could be off wrote this off top of head.
If I do it this way, every time I add a new sensor; I have to go modify the automation. With a blueprint, it is done automatically
I am lazy
good point bro not Lazy just trying to be smart
here read this
just change the motion to moisture job done
The blueprint is missing an action section, this is where am getting it wrong. I used another BP as base but the editor doesn’t like " default: !input ‘actions’ "
blueprint:
name: Detect water and notify
description: detect 'moisture' device-class and if so execute an action.
domain: automation
input:
actions:
name: Actions
description: Notifications or similar to be run. {{sensors}} is replaced with the names of sensors.
selector:
action: {}
variables:
sensors: >-
{% set result = namespace(sensors=[]) %}
{% for state in states.sensor | selectattr('attributes.device_class', '==', 'moisture') %}
{% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %}
{% endfor %}
{% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'moisture') | selectattr('state', '==', 'on') %}
{% set result.sensors = result.sensors + [state.name] %}
{% endfor %}
{{result.sensors|join(', ')}}
trigger:
- type: moist
platform: device
action:
- choose: []
default: !input 'actions'
mode: single
Can you make a link to this blueprint? I was looking for this functionality!
I don’t want to maintain a blueprint, but I created one for my own use for my water sensors. If someone wants to publish properly, feel free to take this.
blueprint:
name: Moisture Sensor
description: Perform action when moisture sensor turns wet
domain: automation
input:
actions:
name: Actions
description: Notifications or similar to be run.
{{ trigger.event.data.new_state.attributes.friendly_name }} will be the name of the
sensor
selector:
action: {}
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:
- choose: []
default: !input 'actions'
mode: single
I create an action on Call service
calling the notify.mobile_app_my_iphone
with data like:
message: 'Leak detected by {{ trigger.event.data.new_state.attributes.friendly_name }}'
data:
push:
sound:
name: default
critical: 1
volume: 1
@ mrmarcsmith
I didn’t have the time to complete it and publish but I will try to do that very soon and publish it.
@ joel_d1
I can use yours and merge with mine if needed, is that ok ?
Here is my simple blueprint that will send a notification to a defined device if moisture is detected by any configured sensor: https://gist.github.com/bbbenji/d4d1fe1856ec54370a422508c8963f2a
It also relays the sensor’s friendly_name
in the message.
Just select where the notification should go and you’re all set.
I know this is a bit off topic but I like this idea and wanted to share my water notification script, I have my water sensor sitting in my sump, so if my pump fails I want it to get me out of bed! The mobile app max volume alert is great for this.
water_alarm:
sequence:
- alias: Water Alarm
repeat:
while:
- condition: state
entity_id: binary_sensor.basement_water_sensor
state: 'on'
# Don't do it too many times
- condition: template
value_template: "{{ repeat.index <= 60 }}"
sequence:
- service: notify.mobile_app_chriss_iphone
data:
title: "Water Alarm Triggered!"
message: "Check the sump pump in the basement!"
data:
push:
sound:
name: default
critical: 1
volume: 1.0
- delay: '00:01:00'
- service: notify.chris_sms
data:
title: "Water Alarm Triggered"
message: "Check the sump pump in the basement"
- delay: '00:01:00'
Nice. But I have a notify.group and with the existing blueprint I am not allowed to use this
action:
domain: mobile_app
type: notify
device_id: !input notify_device
I can only select one mobile, what do I have to change to be able to select my:
notify.ios_group_phones in the blueprint
Blueprint’s device selector won’t show groups, just mobile apps (which makes sense, given it has a selector of mobile_app
). Maybe someone else can expand on the issue.
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