Daemon that will pull sensor data from a network of sensor hosting a micro HTTP API.
Project description
Lightweight sensor status pulling daemon.
Installation:
pip install SensorNet
Run instructions:
Run once: sensornet -c <path/to/config.yaml>
Run daemon: sensornet -d - c <path/to/config.yaml>
Configuration:
Create a configuration file in /etc/sensornet/sensor.yaml
daemon_name: SensorNetDaemon
backend:
driver: sqlalchemy
url: "engine://username:password@host:port/dbname"
networks:
- name: network0
ip_addresses:
- 10.0.0.1/32
- 10.0.1.10 - 10.0.1.20
sensor_prefix: sn0
api_port: 80
api_location: "/"
cron: "* * * * * *"
daemon_name
Name for the daemon that will be sent to the backend.
backend
driver: name of the backend module to use. Modules should be installed in /lib/sensor_net/backend_driver/module.py
This section will contain the module configuration, and will be passed as a dict to the get_driver function.
SensorData = namedtuple('SensorData', ["name", "value", "datetime_utc"])
class BackendDriver(Protocol):
def write(self, network_name: str, network_prefix: str, sensor_address: str, data: list[SensorData]):
"""Writes all data to the backend"""
...
def get_driver(name: str, configuration: dict) -> BackendDriver:
"""Instantiate a new BackendDriver from the given configuration"""
raise NotImplementedError("get_backend is not implemented.")
Note: get_driver MUST have parameters types annotations.
networks:
Defines the networks to pull.
A pull is a simple HTTP GET request to http://endpoint/api_location It expects a JSON body containing:
{
"data": [
{
"name": str,
"value": number,
"epoch": number
}, ...
]
}
network_name: the name of the network
ip_addresses: IP address with mask or range of IP addresses
sensor_prefix: prefix for the sensor, it’s recommended to use the sensor prefix for deduplication in the backend.
api_port: port the API is listening to.
api_location: location of the sensor API
cron: interval between polling for this network
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file SensorNet-1.0.post0.dev19.zip.
File metadata
- Download URL: SensorNet-1.0.post0.dev19.zip
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc95aae00bbef6c5b07a3b13554e6529719becc2c0c89c6228fb5da6cecf9ea
|
|
| MD5 |
f37ae41786e79c99d71da59df5217884
|
|
| BLAKE2b-256 |
8f9b0226f4d5bb347a328aa899a45a1d0a4d60a9ade8bdf2f35bc7f41a640521
|