Automation unable to create a device_tracker sensor!

Hi,

I have 3 entities storing respectively latitude, longitude and altitude of a device. I want to use these to keep up-to-date a device_tracker entity so I created an automation with that code:

- id: '1603005245535'
  alias: Position Camino
  description: Camino
  trigger:
  - platform: state
    entity_id: sensor.tracker_latitude
  - platform: state
    entity_id: sensor.tracker_longitude
  condition: []
  action:
  - service: device_tracker.see
    data:
      data_template:
        dev_id: Camino
        gps:
        - '{{ states(''sensor.tracker_latitude'') }}'
        - '{{ states(''sensor.tracker_latitude'') }}'
  mode: parallel
  max: 3

but when it runs it triggers an error stating:

must contain at least one of mac, dev_id

but I have a dev_ïd ! I tried to add also a fake mac id but same :frowning: Any ideas what’s wrong there ? I have checked all docs I could find but no solution working :frowning:

Thanks

Vincèn

you have data_template inside data. Not only is data_template deprecated, but you’re nesting as well. So your data is actually missing dev_id because it only has a single item in it: data_template.

You also have a typo, you’re using latitude twice.

  - service: device_tracker.see
    data:
      dev_id: Camino
      gps:
        - '{{ states(''sensor.tracker_latitude'') }}'
        - '{{ states(''sensor.tracker_longitude'') }}'

Lastly, if you switch to yaml mode, you can take advantage of anchors and extend this to other automations pretty easily with only editing the initial list.

- id: '1603005245535'
  alias: Position Camino
  description: Camino
  trigger:
  - platform: state
    entity_id: &trackers
    - sensor.tracker_latitude
    - sensor.tracker_longitude
  variables:
    trackers: *trackers
  action:
  - service: device_tracker.see
    data:
      dev_id: Camino
      gps: "{{ expand(trackers) | map(attribute='state') | list }}"
  mode: parallel
  max: 3
1 Like