-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunavailable_entities_notification.yaml
100 lines (100 loc) · 3.24 KB
/
unavailable_entities_notification.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
blueprint:
name: Unavailable entity detection & notification
description: Regularly test all entities' status to check for unavailability.
domain: automation
source_url: https://github.com/FrankQ76/public/blob/main/unavailable_entities_notification.yaml
input:
min:
name: test every x min
description: Test is run every x minutes
default: '/30'
selector:
text: {}
monday_enabled:
name: Monday
description: Run test on Monday
default: true
selector:
boolean: {}
tuesday_enabled:
name: Tuesday
description: Run test on Tuesday
default: true
selector:
boolean: {}
wednesday_enabled:
name: Wednesday
description: Run test on Wednesday
default: true
selector:
boolean: {}
thursday_enabled:
name: Thursday
description: Run test on Thursday
default: true
selector:
boolean: {}
friday_enabled:
name: Friday
description: Run test on Friday
default: true
selector:
boolean: {}
saturday_enabled:
name: Saturday
description: Run test on Saturday
default: true
selector:
boolean: {}
sunday_enabled:
name: Sunday
description: Run test on Sunday
default: true
selector:
boolean: {}
exclude:
name: Excluded Entities
description: Entities (e.g. smartphone) to exclude from detection. Only entities
are supported, areas and devices must be expanded!
default: {}
selector:
target: {}
actions:
name: Actions
description: Notifications or similar to be run. {{entities}} is replaced with
the names of unavailable entities.
selector:
action: {}
variables:
monday_enabled: !input monday_enabled
tuesday_enabled: !input tuesday_enabled
wednesday_enabled: !input wednesday_enabled
thursday_enabled: !input thursday_enabled
friday_enabled: !input friday_enabled
saturday_enabled: !input saturday_enabled
sunday_enabled: !input sunday_enabled
current_day: '{{ now().weekday() | int }}'
exclude: !input exclude
entities: "{% set result = namespace(entities=[]) %} {% for state in states %}\n
\ {% if exclude.entity_id is defined %}\n {% if state.state == 'unavailable'
and not state.entity_id in exclude.entity_id %}\n {% set result.entities
= result.entities + [state.name] %}\n {% endif %}\n {% else %}\n {% if
state.state == 'unavailable' %}\n {% set result.entities = result.entities
+ [state.name] %}\n {% endif %}\n {% endif %}\n{% endfor %} {{\"⤵ \\n- \"}}{{result.entities|join('\\n-
')}}"
trigger:
- platform: time_pattern
minutes: !input min
condition:
- condition: template
value_template: "{{ \n (current_day == 0 and monday_enabled) or \n (current_day
== 1 and tuesday_enabled) or \n (current_day == 2 and wednesday_enabled) or\n
\ (current_day == 3 and thursday_enabled) or \n (current_day == 4 and friday_enabled)
or\n (current_day == 5 and saturday_enabled) or\n (current_day == 6 and sunday_enabled)\n}}"
- condition: template
value_template: '{{ entities != "⤵ \n-"}}'
action:
- choose: []
default: !input actions
mode: single
max_exceeded: silent