-
Notifications
You must be signed in to change notification settings - Fork 0
/
zone_change.yaml
29 lines (28 loc) · 935 Bytes
/
zone_change.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
- alias: Notify on family members zone change
trigger:
- platform: state
entity_id:
- person.marina
- person.elena
- person.andrey
to: ~
for:
minutes: 1
condition: "{{ trigger.to_state.state != trigger.from_state.state }}"
action:
- variables:
state_from: "{{ trigger.from_state.state }}"
state_to: "{{ trigger.to_state.state }}"
person: "{{ state_attr(trigger.entity_id, 'friendly_name') }}"
event: >-
{%- if state_from == 'not_home' -%}
{{ 'arrived' if state_to == 'home' else 'arrived at' }}
{%- else -%}
left
{%- endif -%}
zone: "{{ state_to if state_from == 'not_home' else state_from }}"
emoji: "{{ '🏠' if zone == 'home' else '📍' }}"
- service: notify.alexey
data:
message: >-
{{ emoji }} {{ person }} has {{ event }} {{ zone }}