In my early spring code cleaning, I tried to combine the device_tracker.see service to do both home/not_home in one automation, but I fail somewhere with yaml.
Is it possible to send the dev_id and location name from inside the statement?
The automation ran but no devices were created for me.
Turn out the “{{ trigger.from_state.name }}” is not a good device name.
Piggy back on the entity_id does the trick for me, so:
- alias: any ble tracker state
trigger:
- platform: state
entity_id:
- sensor.AddYourOwn
action:
- service: device_tracker.see
data_template:
dev_id: "{{ trigger.to_state.entity_id | regex_replace(find='sensor\\.', replace='', ignorecase=False) }}"
location_name: "{{ trigger.to_state.state }}"