How to access GPS data, such as speed

Hi All,

I am getting good data from the GPS device using gpsd integration:

I am trying to access individual values coming from the GPS, so that I can create automations, or pass them to set_location (Homeassistant.set_location). I can’t figure out how to do it.

sensor.gpsd.speed does not work.

Any other ideas?

I would create template sensors of the values you are trying to use. Then you can use those sensors in your automations.
You can also use templates in you automations directly if you prefer.

1 Like

it should be ‘sensor.gpsd.attributes.speed’

but you will need to modify that depending on how you are using it. But that is the general way you will access the attributes of an entity.

1 Like

Thank you guys, I made a little bit of progress with your help:

I am able to view the attribute in the console, like so:

type: entity
entity: sensor.gps
unit: Knots
attribute: speed
name: Boat Speed

However, the template doesn’t work

  - platform: template
    sensors:
      latitude:
        friendly_name: "Latitude"
        unit_of_measurement: 'Degrees'
        value_template: "{{ sensor.gps.attributes.latitude }}"

and so I can’t access it for automations. What am I doing wrong?

I think I got it, thanks for your help guys!!

sensor:
  - platform: gpsd
  - platform: template
    sensors:
      latitude:
        friendly_name: "Latitude"
        unit_of_measurement: 'Degrees'
        value_template: "{{ state_attr('sensor.gps', 'latitude') }}"

Screen Shot 2020-07-03 at 10.54.52 AM

3 Likes
value_template: "{{ state_attr('sensor.gps', 'latitude') }}"

Edit: too slow.

1 Like

Yeah, that’s what I meant by “you will need to modify that depending on how you are using it.”

The other way would have been

{{ states.sensor.gps.attributes.latitude }}

or even

{{ states(‘sensor.gps.attributes.latitude’) }}.`

EDIT: Never mind that second bit. It won’t work. I’m not sure what I was thinking.

1 Like

What type of GPS device are you using?

GlobalSat BU-353-S4 USB GPS Receiver

Thank you, I will look into it.

1 Like

So is it possible to get this information if gpsd is run in Portainer?
I was thinking of keeping gpsd separate, using it for sending position report emails to MarineTraffic, but it does make sense to let Home Assistant know where the boat is, and making changes to what is on/off and notification based on f.ex. not being docked.

Yes, it is possible, if you can reach it via TCP. Check out hass documentation. You can specify a host and a port there, if it isn’t localhost.

Have you seen my new addon? I am doing just what you are trying to do now.