Skip to main content

gpsd smart home integration, free and open source

gpsd integration for Gladys Assistant

Position, speed and fix of a GNSS receiver shared by gpsd (camper van, boat).

Shows in Gladys the position of a GPS / GNSS receiver shared by gpsd: a camper van, a boat, a cabin, a weather mast. gpsd reads the receiver (USB or serial) on its own machine and shares its reports on the network; this integration connects to it over TCP and reads them. It never touches USB nor a serial port, and never sends anything to the receiver.

This integration has never been tested with a real receiver: it was tested with gpsd 3.25 and gpsfake replaying an NMEA log. Feedback is welcome.

What you get​

One device per gpsd address (Discovery tab), read only:

FeatureUnit / values
Latitudedegrees, rounded (see Precision)
Longitudedegrees, rounded (see Precision)
Speedkm/h, to 0.1
Altitudemetres above sea level, 3D fix only
Coursedegrees from true north, above 2 km/h only
Fix mode1 no fix, 2 2D, 3 3D
Fixtext: no fix, 2D, 3D, 3D DGPS, 3D RTK fixed...
Horizontal errormetres, as estimated by gpsd
Satellites usedcount
Satellites seencount

A value gpsd does not give stays unknown (never 0). Without a fix, only the fix mode and the fix text are published, never a position: Gladys keeps showing the last position, speed, altitude and course received, with their date (an integration cannot erase a value). Below 2 km/h the course is not updated. gpsd sends several reports per second, some without the course or the speed: a value missing from the newest one is taken from a report of the same fix at most 3 seconds old.

Before you start​

  • gpsd must listen on the network: start it with -G (on Debian, set GPSD_OPTIONS="-G" in /etc/default/gpsd). A socket-activated gpsd also needs sudo systemctl edit gpsd.socket with the lines below (the empty ListenStream= clears the local-only addresses first), then sudo systemctl restart gpsd.socket gpsd:

    [Socket]
    ListenStream=
    ListenStream=/run/gpsd.sock
    ListenStream=0.0.0.0:2947

    Check with gpspipe -w <address> from another machine.

  • TCP port 2947 (or yours) must be reachable from Gladys. gpsd has no password: keep it on your local network, never open it to the internet.

Configuration​

  • gpsd address: name or IP address of the gpsd machine, :port if not 2947 (IPv6 in brackets: [fd00::12]:2947).
  • Receiver (optional): only if gpsd reads several receivers, the path of the one to follow as gpsd names it (/dev/ttyACM0). Empty: the first one that reports; if gpsd deactivates it, the next one that reports is followed. The test button lists the other receivers seen; the status names them only when the configured receiver sends nothing.
  • Publication: gpsd reports about once a second; the integration keeps the newest report and publishes at most every 10 s, 30 s, 1 min (default), 5 min or 15 min, only the values that changed (an unchanged value is sent again once an hour). The first report is published at once, unless a publication left less than one interval ago.
  • Position precision: about 1 m (5 decimals), 10 m (4, default), 100 m (3) or 1 km (2). The altitude follows (0.1 m, 1 m, 10 m, 100 m).

Privacy​

A position is personal data. It is rounded before it reaches Gladys, never written in the logs, the status nor the answer of the test button. Latitude, longitude, altitude, course and the fix text keep no history by default (together they would draw your trips); speed, horizontal error, fix mode and satellites keep it. You may change this for each feature in Gladys.

Status and test button​

The Configuration screen shows the state of the connection: connected with a fix, no fix yet, no active receiver, a configured receiver that sends nothing (with the receivers gpsd reports instead), no report for a minute, or the reason of a failure (refused, unknown name, unreachable, not gpsd, another protocol version, gpsd stopped answering). While connected, the status changes at most once every 10 seconds (a fix that comes and goes does not flood Gladys). A lost connection is tried again after 5 s, then 10, 20... up to 5 minutes. The Test the connection button tells the same state with the kind of fix (2D, 3D, DGPS...), the satellites and the pace; it never opens a new connection.

How it works​

The integration reads the gpsd banner (VERSION, protocol 3), asks ?WATCH={"enable":true,"json":true}; (JSON reports only, never NMEA), and reads the TPV (position, speed, fix), SKY (satellites) and DEVICE(S) (receivers) objects. A connection silent for a minute is asked ?VERSION;; no answer within 10 s and it is closed and tried again. Lines are bounded (16 KiB) and so is the flow (256 KiB/s).

Identity of the device​

The device id is a digest of the gpsd address (host:port): another address makes another device; a receiver moved to another USB port stays the same device.

Unofficial integration, not affiliated with the GPSD project.

Configuration settings​

These are the settings gpsd asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
How it workssectionNogpsd is the service that reads a GPS / GNSS receiver (USB or serial) and shares it on the network, on TCP port 2947. Gladys connects to it, reads its reports (gpsd JSON protocol) and turns them into one device (Discovery tab): latitude, longitude, speed, altitude, course, fix, horizontal error and satellites. Read only: nothing is ever sent to the receiver. gpsd must listen on the network (option -G) and be reachable from Gladys. A position is personal data: it is rounded as chosen below, never written in the logs; latitude, longitude, altitude and course are kept without history by default. Unofficial integration, not affiliated with the GPSD project.
gpsd addressstringYesName or IP address of the machine running gpsd, followed by :port if gpsd does not listen on 2947.
Receiver (optional)stringNoOnly when gpsd reads several receivers: the path of the one to follow, as gpsd names it. Empty: the first receiver that reports.
PublicationselectYesgpsd reports about once a second; Gladys keeps the newest report and publishes at most at this pace, only the values that changed.
Position precisionselectYesLatitude and longitude are rounded before they reach Gladys (the altitude too). Coarser keeps your exact position private.

How to install gpsd in Gladys​

  1. In Gladys, open Integrations: gpsd appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/lm1lc3n7/gladys-gpsd:0.1.1), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/LM1LC3N7/gladys-gpsd.

gpsd requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

gpsd is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by LM1LC3N7, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂