Created
February 10, 2022 00:28
-
-
Save fabiosoft/728a4494db805cd2c28cbb3d461e8c45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment