GPS Position for Map using Lat and Lon via MQTT

Hi Everbody,

I’m trying to plot the GPS Position of my car in a Map Dashboard. I do get the Latitude and Longitude into HA via MQTT as separate videos. That works fine:

    - name: "California Position Latitude"
      unique_id: "califonia_position_latitude"
      state_topic: 'California/Location/Latitude'

    - name: "California Position Longitude"
      unique_id: "califonia_position_longitude"
      state_topic: 'California/Location/Longitude'

    - name: "California Position Update"
      unique_id: "califonia_position_update"
      state_topic: 'California/Location/Updated'

From my understanding (and some tutorials I found), I need to create a GPS object to plot this in the map. So I created the following in my automations.yaml:

- alias: Get California Current Position
  trigger:
    platform: state
    entity: califonia_position_latitude, califonia_position_longitude
  action:
    service: device_tracker.see
    data_template:
      dev_id: california_position
      gps:
        - "{{ states('sensor.califonia_position_latitude') }}"
        - "{{ states('sensor.califonia_position_longitude') }}"

Unfortunately this does not work. I don’t see the device_tracker created.

What am I doing wrong?

Thanks, Carsten

Have you created the “device” in known_devices.yaml?

I have…but that didn’t helped…

I think i did something similar last year, got it working but removed it somewhere along the way. The code look similar except i explictly said it was a float

        - "{{ states('sensor.califonia_position_latitude')|float }}"
        - "{{ states('sensor.califonia_position_longitude')|float }}"

Problably not the solution but i remember messing around with this

Not sure if that changed over time but i seperated the triggers. Or, better said, i never used them like you did. When I look at the documentation

  trigger:
    - platform: state
      entity_id:
        - sensor.one
        - sensor.two
        - sensor.three

is the trigger correct?

- alias: Get California Current Position
  trigger:
    - platform: state
      entity_id:
        - sensor.califonia_position_latitude
        - sensor.califonia_position_longitude

[edited for typos]

Well, the idea is to run this whenever the latitude or longitude sensor get’s updated. And the sensors definitely get updates…that’s something I checked…

You can also try a MQTT trigger like this:

  trigger:
    - platform: mqtt
      topic: "California/Location/#"

Never tried it as a trigger like this with the multi-level wildcard (#), but should trigger for every message received under “California/Location/”.
Or only run for new data from latitude and longitude:

  trigger:
    - platform: mqtt
      topic: "California/Location/Latitude"
    - platform: mqtt
      topic: "California/Location/Longitude"

What’s your problem now?
The device_tracker entity is not created?