alias: Notify Adults At Home
variables:
all_adults:
- device_tracker.heathers_phone
- device_tracker.andy_s_iphone
- device_tracker.david_barratts_iphone
- device_tracker.shaughn_samsung
ios_adults:
- device_tracker.heathers_phone
- device_tracker.andy_s_iphone
- device_tracker.david_barratts_iphone
android_adults:
- device_tracker.shaughn_samsung
title: ""
message: ""
critical: false
sequence:
- if: "{{ critical }}"
then:
- repeat:
for_each: |-
{{
states.person |
selectattr('state', 'eq', 'home') |
map(attribute='attributes.source') |
select('in', 'ios_adults') |
list
}}
sequence:
- service: notify_mobile_app_{{ repeat.item.split('.')[1] }}
data:
title: "{{title}}"
message: "{{message}}"
data:
push:
sound:
name: default
critical: 1
volume: 0
- repeat:
for_each: |-
{{
states.person |
selectattr('state', 'eq', 'home') |
map(attribute='attributes.source') |
select('in', 'android_adults') |
list
}}
sequence:
- service: notify_mobile_app_{{ repeat.item.split('.')[1] }}
data:
title: "{{title}}"
message: "{{message}}"
data:
ttl: 0
priority: high
else:
- repeat:
for_each: |-
{{
states.person |
selectattr('state', 'eq', 'home') |
map(attribute='attributes.source') |
select('in', 'adults') |
list
}}
sequence:
- service: notify_mobile_app_{{ repeat.item.split('.')[1] }}
data:
title: "{{title}}"
message: "{{message}}"
mode: single