Skip to content

Instantly share code, notes, and snippets.

@gottaloveit
Created December 27, 2025 11:20
Show Gist options
  • Select an option

  • Save gottaloveit/278e2af19e15106434dc7fa4680ff217 to your computer and use it in GitHub Desktop.

Select an option

Save gottaloveit/278e2af19e15106434dc7fa4680ff217 to your computer and use it in GitHub Desktop.
my HAOS, RPI OS, RPI, GPSD, GPS, MQTT config files
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyACM0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-Gn"
# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"
- id: 'update_ha_location_from_gps_mqtt'
alias: Update Location
description: 'Updates my HA location from gpsd through mqtt'
triggers:
- trigger: time_pattern
minutes: /3
conditions:
- condition: state
entity_id: sensor.gps_coordinates
state:
- 3D fix
actions:
- action: homeassistant.set_location
data:
latitude: "{{ state_attr('sensor.gps_coordinates','latitude') }}"
longitude: "{{ state_attr('sensor.gps_coordinates','longitude') }}"
mode: single
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
[Unit]
Description=GPS (Global Positioning System) Daemon Sockets
[Socket]
ListenStream=/run/gpsd.sock
#ListenStream=[::1]:2947
#ListenStream=127.0.0.1:2947
# To allow gpsd remote access, start gpsd with the -G option and
# uncomment the next two lines:
ListenStream=[::]:2947
ListenStream=0.0.0.0:2947
SocketMode=0600
BindIPv6Only=yes
[Install]
WantedBy=sockets.target
sensor:
- name: "GPS Coordinates"
unique_id: gps_coordinates
availability_topic: "gateway/availability"
state_topic: "homeassistant/device_tracker/ha_gps/attributes"
value_template: "{{ value_json.mode }}"
json_attributes_topic: "homeassistant/device_tracker/ha_gps/attributes"
json_attributes_template: "{{ value_json | tojson }}"
[{"id":"5c7ed1dc1a8769e0","type":"tab","label":"Send gpsd data to HA mqtt","disabled":false,"info":"","env":[]},{"id":"38377e4901a2f138","type":"gpsd","z":"5c7ed1dc1a8769e0","name":"rv_gps","hostname":"192.168.50.175","port":"2947","tpv":true,"sky":true,"info":true,"device":false,"gst":true,"att":false,"x":190,"y":140,"wires":[["ed0819674d170420"]]},{"id":"ed0819674d170420","type":"switch","z":"5c7ed1dc1a8769e0","name":"","property":"payload.class","propertyType":"msg","rules":[{"t":"eq","v":"TPV","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":220,"wires":[["fc233df5116bc030"]],"outputLabels":["TPV"]},{"id":"81afe0a149b602ca","type":"mqtt out","z":"5c7ed1dc1a8769e0","name":"tpv","topic":"homeassistant/device_tracker/ha_gps/attributes","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"1767f3ec.d1e33c","x":590,"y":300,"wires":[]},{"id":"fc233df5116bc030","type":"function","z":"5c7ed1dc1a8769e0","name":"recreateGps","func":"let modes = [\"Unknown\",\"No fix\",\"2D fix\",\"3D fix\"]\nlet old = msg.payload;\n\nlet newMsg = {};\nnewMsg.payload = {};\nnewMsg.payload.mode = modes[old.mode];\nnewMsg.payload.elevation = old.altHAE;\nnewMsg.payload.latitude = parseFloat(old.lat.toFixed(5));\nnewMsg.payload.longitude = parseFloat(old.lon.toFixed(5));\nnewMsg.payload.speed = parseFloat((old.speed * 2.23694).toFixed(2));\n\nreturn newMsg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":220,"wires":[["81afe0a149b602ca"]]},{"id":"1767f3ec.d1e33c","type":"mqtt-broker","name":"ha","broker":"core-mosquitto","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"gateway/availability","birthQos":"2","birthRetain":"true","birthPayload":"online","birthMsg":{},"closeTopic":"gateway/availability","closeQos":"2","closeRetain":"true","closePayload":"offline","closeMsg":{},"willTopic":"gateway/availability","willQos":"2","willRetain":"true","willPayload":"offline","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"64f640812afe2465","type":"global-config","env":[],"modules":{"node-red-contrib-gpsd":"1.0.8"}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment