Is it possible to use an alias in a data_template? I’d like to be able to use the same code for multiple triggers. For example, I’d like to be able to use the alias in the following for the title. How about getting the friendly name for the entity id that triggered the automation?
- alias: Enter Home
trigger:
platform: zone
entity_id: device_tracker.myphone, device_tracker.wifephone, device_tracker.kidphone
zone: zone.home_zone
event: enter
action:
- service: notify.notify
data_template:
title: {{ ??? }}
message: {{ ??? }}
It doesn’t appear you can specify multiple zones or events in the same trigger, is that correct?
An automation can have more than one trigger. Whenever any of them “fire” the automation’s actions will run. So you could add another trigger for each zone you want to be notified about when someone enters it.
However, it might be simpler to do this another way, if I understand what you’re trying to do. Whenever a device_tracker enters a zone, the device_tracker’s state will become the friendly name of that zone (except for zone.home, in which case it will just be home.) So you could do something like this:
- alias: Enter a zone
trigger:
platform: state
entity_id: device_tracker.myphone, device_tracker.wifephone, device_tracker.kidphone
condition:
condition: template
value_template: "{{ trigger.to_state.state != 'not_home' }}"
action:
service: notify.notify
data_template:
message: >
{{ trigger.to_state.name }} entered zone {{ trigger.to_state.state }}.