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
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:
@ 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 ?
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'
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 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.
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?
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.”
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?