-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature-sensor-state-detection-notification-for-all-temp-sensors.yaml
64 lines (64 loc) · 2.37 KB
/
temperature-sensor-state-detection-notification-for-all-temp-sensors.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
blueprint:
name: State detection & notification for all temperature sensors
description: Regularly test all sensors with 'temperature' device-class for defined state will be sent to warning service
domain: automation
input:
warning_state:
name: State used for warning
description: Temperature sensors with the state defined in warning_state, will be sent to warning service
default: unavailable
time:
name: Time to test on
description: Test is run at configured time
default: '10:00:00'
selector:
time: {}
day:
name: Weekday to test on
description: 'Test is run at configured time either everyday (0) or on a given
weekday (1: Monday ... 7: Sunday)'
default: 0
selector:
number:
min: 0.0
max: 7.0
mode: slider
step: 1.0
exclude:
name: Excluded Sensors
description: Sensors that you want to exclude from monitoring!
default:
entity_id: []
selector:
target:
entity:
device_class: temperature
actions:
name: Actions
description: Notifications or similar to be run. {{sensors}} is replaced with
the names of sensors being in the state defined.
selector:
action: {}
source_url: https://gist.github.com/ovimano/temperature-sensor-state-detection-notification-for-all-temp-sensors
variables:
day: !input day
threshold: !input threshold
exclude: !input exclude
sensors: "{% set result = namespace(sensors=[]) %} {% for state in states.sensor
| selectattr('attributes.device_class', '==', 'temperature') %}\n {% if 0 <= state.state
| int(-1) < threshold | int and not state.entity_id in exclude.entity_id %}\n
\ {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state
~ ' %)'] %}\n {% endif %}\n{% endfor %} {% for state in states.binary_sensor
| selectattr('attributes.device_class', '==', 'temperature') | selectattr('state',
'==', 'on') %}\n {% if not state.entity_id in exclude.entity_id %}\n {% set
result.sensors = result.sensors + [state.name] %}\n {% endif %}\n{% endfor %}
{{result.sensors|join(', ')}}"
trigger:
- platform: time
at: !input time
condition:
- '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'
action:
- choose: []
default: !input actions
mode: single