gps#

Description#

This plugin can interact with a GPS device compatible with gpsd and emit events when the location changes.

It requires gpsd to run on a system with a compatible GPS device connected - most of the off-the-shelf GPS devices over USB or serial interfaces should tick the box.

For example, if your GPS device communicates over USB and is available on /dev/ttyUSB0, you can start the gpsd daemon with the following command before starting Platypush:

[sudo] gpsd /dev/ttyUSB0 [-S 2947]

It will expose GPS events over the port 2947 by default, and you can subscribe to them through this plugin.

Configuration#

gps:
  # [Optional]
  # gpsd daemon server name/address (default: localhost).
  # gpsd_server: localhost  # type=str

  # [Optional]
  # Port of the gpsd daemon (default: 2947).
  # gpsd_port: 2947  # type=int

  # [Optional]
  # How long to wait before polling the GPS device
  # again in case of error (default: 5 seconds).
  # poll_interval: 5.0  # type=float

  # [Optional]
  # If True, the GPS polling will be enabled when the
  # plugin starts (default: True). Otherwise, it'll have to be enabled by
  # calling the `GpsPlugin.enable <https://docs.platypush.tech/platypush/plugins/gps.html#platypush.plugins.gps.GpsPlugin.enable>`_ action.
  # enable_on_start: True  # type=bool

  # [Optional]
  # How long we should wait for any running
  # threads/processes to stop before exiting (default: 5 seconds).
  # stop_timeout: 5  # type=Optional[float]

  # [Optional]
  # If set to True then the plugin will not monitor
  # for new events. This is useful if you want to run a plugin in
  # stateless mode and only leverage its actions, without triggering any
  # events. Defaults to False.
  # disable_monitor: False  # type=bool

Dependencies#

pip

pip install gps

Alpine

apk add gpsd py3-gpsd

Debian

apt install python3-gps gpsd

Fedora

yum install gpsd python-gpsd

Arch Linux

pacman -S gpsd

Triggered events#

Actions#

Module reference#

class platypush.plugins.gps.GpsPlugin(gpsd_server: str = 'localhost', gpsd_port: int = 2947, poll_interval: float = 5.0, enable_on_start: bool = True, **kwargs)[source]#

Bases: RunnablePlugin

This plugin can interact with a GPS device compatible with gpsd and emit events when the location changes.

It requires gpsd to run on a system with a compatible GPS device connected - most of the off-the-shelf GPS devices over USB or serial interfaces should tick the box.

For example, if your GPS device communicates over USB and is available on /dev/ttyUSB0, you can start the gpsd daemon with the following command before starting Platypush:

[sudo] gpsd /dev/ttyUSB0 [-S 2947]

It will expose GPS events over the port 2947 by default, and you can subscribe to them through this plugin.

__init__(gpsd_server: str = 'localhost', gpsd_port: int = 2947, poll_interval: float = 5.0, enable_on_start: bool = True, **kwargs)[source]#
Parameters:
  • gpsd_server – gpsd daemon server name/address (default: localhost).

  • gpsd_port – Port of the gpsd daemon (default: 2947).

  • poll_interval – How long to wait before polling the GPS device again in case of error (default: 5 seconds).

  • enable_on_start – If True, the GPS polling will be enabled when the plugin starts (default: True). Otherwise, it’ll have to be enabled by calling the enable() action.

disable()[source]#

Disable the GPS polling.

enable()[source]#

Enable the GPS polling.

main()[source]#

Implementation of the main loop of the plugin.

start()#

Start the plugin.

status()[source]#
Returns:

The current GPS status:

{
  "altitude": 100,
  "devices": {
    "/dev/ttyUSB0": {
      "activated": "2021-08-01T00:00:00",
      "baudrate": 9600,
      "cycle": 1,
      "driver": "NMEA",
      "mode": "3D",
      "native": false,
      "parity": "N",
      "path": "/dev/ttyUSB0",
      "stopbits": 1,
      "subtype": "AXN_2.31_3339_13101700,5632,PA6H,1.0"
    }
  },
  "latitude": 45.4642,
  "longitude": 9.19,
  "satellites_used": 4,
  "speed": 10,
  "timestamp": "2021-08-01T00:00:00"
}

stop()#

Stop the plugin.

wait_stop(timeout=None)#

Wait until a stop event is received.