[SOLVED] Device Tracker help

Hi,

I there a way to create a device tracker from the config below for my car.

rest:
    resource: https://example.com
    scan_interval: 10 
    sensor:
      - name: "Uplander LT GPS"
        json_attributes_path: "data.gps"
        value_template: "ok"
        json_attributes:
          - "longitude"
          - "latitude"
          - "gpsSpeed"
          - "acc"
sensor:
  uplander_lt_longitude:
    friendly_name: "Uplander LT Longitude"
    value_template: "{{ state_attr('sensor.uplander_lt_gps', 'longitude') }}"
  uplander_lt_latitude:
    friendly_name: "Uplander LT Latitude"
    value_template: "{{ state_attr('sensor.uplander_lt_gps', 'latitude') }}"

You need to create a device tracker. Also check out the proximity integration.

Hi,

I am getting this error invalid latitude for dictionary value @ data[‘gps’]

automation:
         - trigger:
               platform: state
               entity_id: sensor.uplander_lt_latitude, sensor.uplander_lt_longitude
           action:
               service: device_tracker.see
               data_template:
                     dev_id: Uplander LT Tracker
                     gps:
                        - "{{ states('sensor.uplander_lt_latitude') }}"
                        - "{{ states('sensor.uplander_lt_longitude') }}"

So what are the values of those sensors at the time of getting the error?

Manually ran the automation after everything started. It fixed it.

Will it update the coordinates every time they change or do it need to define scan interval or something? Because each time I restart Home Assistant I have to trigger automation manually.

It’s hard to say without knowing what those GPS sensors are but normally in HA a polling sensor will update check for an update every 30 sec (or maybe it is 60 sec) by default, and otherwise a change of a sensor’s will be immediate. In either case, if the value has changed it should cause your automation to trigger.

But maybe just check your syntax of the trigger. I’m not sure about the form you’re using.

I think it should be either of these two options:

- trigger:
    platform: state
    entity_id: [sensor.uplander_lt_latitude, sensor.uplander_lt_longitude]
- trigger:
    platform: state
    entity_id:
      - sensor.uplander_lt_latitude
      - sensor.uplander_lt_longitude

It doesn’t trigger when restarted. It works fine after triggering manually once, tried the above two methods same results.

- trigger:
     platform: state
     entity_id:
          - sensor.uplander_lt_latitude
          - sensor.uplander_lt_longitude
    action:
        service: device_tracker.see
        data_template:
              dev_id: Uplander_LT_Tracker
              gps:
                - "{{ states('sensor.uplander_lt_latitude') }}"
                - "{{ states('sensor.uplander_lt_longitude') }}"

There is an HA started event you could use.

Thanks,

It works now at every restart,

- id: '1622526317953'
  alias: Uplander Tracker Sensor
  description: Update at Startup of Home Assistant
  trigger:
  - platform: homeassistant
    event: start
  condition: []
  action:
  - service: automation.trigger
    target:
      entity_id: automation.automation_9
  mode: single