Hi,
I have to types of notifications: a normal notification and an alert - both come in two flavours: to all people or only people who are at home.
I successfully created a notification system for the normal notification using a script with service_template
, see below that takes care of presence.
I have not yet managed to send alerts only to people who are at home. Any ideas?
Here is my code for the normal stuff. At the end of an automation I call
action:
- service: notify_people_who_are_present
data:
title: foo
message: bar
and the script looks like this
notify_people_who_are_present:
alias: Notify people who are present
sequence:
- service_template: >
{% if is_state('person.stefan', 'home') %}
notify.mobile_app_swaiphone
{% else %} {% endif %}
data_template:
title: '{{ title }}'
message: '{{ message }}'
- service_template: >
{% if is_state('person.julia', 'home') %}
notify.mobile_app_jphone
{% else %} {% endif %}
data_template:
title: '{{ title }}'
message: '{{ message }}'
- service_template: >
{% if is_state('person.anna', 'home') %}
notify.mobile_app_iphone_von_anna
{% else %} {% endif %}
data_template:
title: '{{ title }}'
message: '{{ message }}'
mode: single
That was fairly easy. How do I create an alert that notifies certain people based on a condition such as presence? I didnāt succeed using service templates
fake_alert:
name: "fake name"
done_message: fake done
entity_id: sensor.swa_fake
state: 'on' # Optional, 'on' is the default value
repeat:
- 1
can_acknowledge: true # Optional, default is true
# skip_first: true # Optional, false is the default
notifiers:
- urgent_notification
Apparently, one cannot use service templates within notifiers?
- platform: group
name: urgent_notification
services:
- service: mobile_app_swaiphone
data:
title: "Title"
data:
push:
sound:
name: default
critical: 1
volume: 0.3