/
Person_Alert_Blueprint.yaml
274 lines (241 loc) 路 10.5 KB
/
Person_Alert_Blueprint.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
blueprint:
name: Person Alert Monitor - 2024-01-24
author: SirGoodenough
description: >
This BluePrint will monitor a person or
persons, and when they 'enter' or 'leave' the zone or zones you pick,
it will trigger an action for both enter and leave phases.
Yes, it will watch multiple people and multiple zones at the same time!
I use this BluePrint to follow family members around during their day so
that the family members at home know where their loved ones are.
I used this to eliminate over 2 dozen separate Automations and Scripts
in my Home set-up. The multiple person/multiple zone watch ability
is the key.
The monitored areas need to be set up as zones in Home Assistant. SEE:
[HA ZONES LINK](https://www.home-assistant.io/integrations/zone/)
[![Open your Home Assistant instance and show your zones.](https://my.home-assistant.io/badges/zones.svg)](https://my.home-assistant.io/redirect/zones/)
The person needs LAT/LOG software running to report their location.
I use Life360, but the Home Assistant App running on their phone will also
work. There are likely other location monitoring methods but I am not
aquainted with any of them. SEE:
[![Open your Home Assistant instance and show your people.](https://my.home-assistant.io/badges/people.svg)](https://my.home-assistant.io/redirect/people/)
[LIFE360 INTEGRATION LINK ](https://www.home-assistant.io/integrations/life360/)
[PERSON INTEGRATION LINK ](https://www.home-assistant.io/integrations/person/)
馃摡 There is not an official version control system for Blueprints. However I have
found something that comes pretty close. It is not perfect, but for **MOST**
Blueprints, it does just fine. I encourage you to check this script out and use
it to easily check if I have updated this blueprint. 馃敆 [koter84 Blueprint Update Script](https://github.com/koter84/HomeAssistant_Blueprints_Update/)
[Community link for this blueprint](https://community.home-assistant.io/t/person-alert-blueprint/542209)
source_url: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.yaml
homeassistant:
min_version: 2023.8.0
domain: automation
input:
people2monitor:
name: Person or People to follow
description: >
Select the Person you want this BP to trigger on for this action.
Multiples are allowed.
selector:
entity:
multiple: true
filter:
- domain: person
zone2monitor:
name: Zone to watch
description: >
Select the Zone you want this BP to trigger on when this person
enters or leaves it.
If you want to select all the zones you have listed in this HA instance
then use the default. If you want to pick individual zones be sure to
override the default because it auto-picks all.
Multiples are allowed.
default: '{{ states.zone | map(attribute="entity_id") | list }}'
selector:
entity:
multiple: true
filter:
- domain: zone
hold_period:
name: Hold Period
description: >
Sometimes devices want to disconnect and connect often,
Home Assistant deals with this using a considered-on or considered-off time.
This is the same thing.
Sometimes you don't need anything here.
I suggest you try the default 00:00:00 here and add time if you need it.
Using this means the automation will be running the entire time period
that you select and will not be available for other triggers.
This time is delay is not effective if automation is in parallel mode.
default:
hours: 0
minutes: 0
seconds: 0
selector:
duration:
enter_action:
name: Enter the Zone Action
description: >
Build the action here that you want to happen when they enter
this zone. There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md)
If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml)
If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml)
There is also a built-in [Actionable Notification Script Blueprint](https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml)
that could work here. It is included with Home Assistant.
default: []
selector:
action: {}
leave_action:
name: Leave the Zone Action
description: >
Build the action here that you want to happen when they leave
this zone. There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md)
If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml)
If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml)
default: []
selector:
action: {}
jump_action:
name: Jump known zone to known zone Action
description: >
Build the action here that you want to happen when both the
zone they left and the zone they entered is known, but not the same zone.
There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md)
If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml)
If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml)
default: []
selector:
action: {}
enable_time:
name: Time of day to begin action(s)
description: >
Set this for the time of day you want to allow action(s) to begin.
Leave as is to always be enabled.
default: 00:00:00
selector:
time: {}
disable_time:
name: Time of day to end action(s)
description: >
Set this for the time of day you want action(s) to end.
Leave as is to always be enabled.
default: 00:00:00
selector:
time: {}
weekday:
name: Day of the week to allow action(s)
description: >
Change options if you want to include or exclude any specific day.
All days are selected by default.
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
options:
- label: Monday
value: mon
- label: Tuesday
value: tue
- label: Wednesday
value: wed
- label: Thursday
value: thu
- label: Friday
value: fri
- label: Saturday
value: sat
- label: Sunday
value: sun
custom_value: false
multiple: true
additional_conditions:
name: Additional conditions
description: |
Extra conditions you may want to add to this automation
(Example: Home occupied, TV on, etc)
default: []
selector:
condition:
trigger:
- platform: state
id: Persons state has changed
entity_id: !input people2monitor
variables:
people2monitor_var: !input people2monitor
zone2monitor_var: !input zone2monitor
friend_zone: >
{% set ns = namespace(zone=[]) %}
{% for z in zone2monitor_var %}
{% set ns.zone = ns.zone + [states[z].attributes.friendly_name | lower] %}
{% endfor %}
{{ ns.zone }}
to_state: '{{ trigger.to_state.state | lower }}'
from_state: '{{ trigger.from_state.state | lower }}'
condition:
- alias: Make sure there even was a move
condition: template
value_template: '{{ to_state != from_state }}'
- alias: Make sure it's not an I'm Lost move
condition: template
value_template: >
{{ not to_state in ('unknown','unavailable','none','None','') and
not from_state in ('unknown','unavailable','none','None','') }}
- alias: Only allow execution within selected Hours / Weekdays
condition: time
after: !input 'enable_time'
before: !input 'disable_time'
weekday: !input 'weekday'
- alias: User pick
condition: !input additional_conditions
action:
- alias: Determine if there was an actionable event
choose:
- conditions:
- alias: Has Person arrived at Zone?
condition: and
conditions:
- condition: template
alias: person is in target zone
value_template:
'{{ to_state in friend_zone }}'
- condition: template
alias: person is arriving from another zone
value_template:
'{{ not from_state in friend_zone }}'
sequence: !input enter_action
- conditions:
- alias: Person left Zone?
condition: and
conditions:
- alias: Person was in Zone
condition: template
value_template:
'{{ from_state in friend_zone }}'
- alias: Person not in zone now
condition: template
value_template:
'{{ not to_state in friend_zone }}'
sequence: !input leave_action
- conditions:
- alias: Person jumped from known zone to known zone
condition: and
conditions:
- alias: Person left known zone
condition: template
value_template:
'{{ from_state in friend_zone }}'
- alias: Person arrived in known zone
condition: template
value_template:
'{{ to_state in friend_zone }}'
sequence: !input jump_action
- alias: Time delay to hold on devices that disconnect often (if needed)
delay: !input hold_period
mode: queued
max: 10