Sensors

Sensor Base Class

Plugin and abstract base class for external sensors, such as weather sensors.

They’re specifically for plugins that connect to and sporadically query some external data source.

Similar to missions, these are a special type of plugin with extra functions to support their intended purpose. The core extra component is the get_data() function, which should return whatever data the sensor provides. Like missions, sensor modules go into their own special folder sensors. Each sensor module can contain exactly one specific sensor plugin, which must subclass Sensor and end with “Sensor”

Note that sensors are not callback based, so data sources that should be processed continuously should not be implemented as a sensor.

class dronemanager.plugins.sensor.SensorPlugin(dm, logger, name)

Bases: Plugin

This plugin handles loading and management of sensor plugins.

Only supports two CLI commands:

  • load: Load a new sensor, optionally with a custom name to have multiple sensors of the same type

  • status: Log information about currently loaded sensors, by calling Sensor.status()

sensors

A dictionary with the sensor names as keys and their associated sensor objects.

PREFIX: str = 'sensor'

(class attribute) The prefix for the CLI commands, “sensor” by default.

Type:

PREFIX

async close()

Stop all sensors.

Called on DroneManager exit.

sensor_options()

Get the possible sensor files, by traversing the sensor directory.

async load(sensor_module: str, name: str | None = None)

Load a new sensor, which work like plugins with the name taking the role of the prefix.

Parameters:
  • sensor_module – The python module with the sensor class that should be loaded.

  • name

Returns:

async status()

Status of running missions and missions that could be loaded.

class dronemanager.plugins.sensor.Sensor(dm, logger, name='YOUDIDSOMETHINGWRONG')

Bases: Plugin, ABC

PREFIX: str = 'YOUDIDSOMETHINGWRONG'

(class attribute) The prefix for the CLI commands.

async start()

This function is called when the sensor plugin is loaded to automatically start any background functions.

async close()

This function must end all running asyncio tasks. By default, all tasks in self._running_tasks are cancelled.

abstractmethod async connect(*args, **kwargs)

Connect to a sensor.

abstractmethod async get_data()

Should return whatever information the sensor provides,

async log_data()
abstractmethod async status()

Should write information about the current status of the sensor to the logger under INFO.

abstractmethod async disconnect()

Disconnect from a sensor. Should handle any socket clearing etc.

async reconnect()

Sensors list

Ecowitt

Sensor package for an ecowitt gw1100

class dronemanager.sensors.ecowitt.WeatherDataEntry(name: str, value: float = math.nan, unit: str = '')

Bases: object

class dronemanager.sensors.ecowitt.WeatherData(timestamp=None)

Bases: object

classmethod from_dict(input_dict, timestamp=None)
parse_xml_entry(entry)
to_json_dict()

Create a json serializable dictionary

classmethod from_json_dict(json_dict)

Recreate the object from a json serialized dictionary

class dronemanager.sensors.ecowitt.EcoWittSensor(dm, logger, name='ecowitt')

Bases: Sensor

Class for EcoWitt Weather stations that support their HTTP API.

async connect(ip: str)

No connection procedure

async get_data() WeatherData | None

Should return whatever information the sensor provides,

async status()

No status as such to report.

async disconnect()

No disconnect procedure.