masterov
(Alexei Masterov)
July 3, 2020, 2:05pm
1
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
masterov
(Alexei Masterov)
July 3, 2020, 2:48pm
4
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?
masterov
(Alexei Masterov)
July 3, 2020, 2:53pm
5
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') }}"
3 Likes
tom_l
July 3, 2020, 2:55pm
6
value_template: "{{ state_attr('sensor.gps', 'latitude') }}"
Edit: too slow.
1 Like
masterov:
I think I got it,
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
carltonb
(Carlton Brooks)
July 3, 2020, 3:08pm
8
What type of GPS device are you using?
carltonb
(Carlton Brooks)
July 4, 2020, 2:52pm
10
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.
masterov
(Alexei Masterov)
July 6, 2020, 6:21pm
12
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.
corvy
(Corvy)
June 19, 2023, 10:21pm
13
Have you seen my new addon? I am doing just what you are trying to do now.
This is a gpsd — a GPS service daemon to MQTT Home Assistant Addon.
This addon will run gpsd and serve the data to MQTT and show a device tracker device (device_tracker.gpsd_location). The addon has been tested with Mosquitto MQTT addon but can also be configued to use another broker if wanted. The idea is to update the home zone in Home Assistant with the actual position from gpsd, in order to run automations based on actual position. Perfect for installations of Home Assistant in cars, carava…