Sensor Wrappers (OzWrapper)
Each wrapper abstracts over one or more hardware drivers for a specific
measurement category. All wrappers extend SensorBase.SensorBase.GenericSensor.
Environmental
OzTemp – Temperature & Humidity
Temperature, humidity, pressure, and dew-point sensor wrapper.
Abstracts over multiple hardware drivers – BME280, SHT31, SHT41, DS18B20, ES12248, MPL1152, LPS25HB, and ATH20 – providing a unified interface for ambient temperature, relative humidity, barometric pressure, and dew-point readings through the GenericSensor contract.
- class OzWrapper.OzTemp.OzTemp.OzTemp[source]
Bases:
GenericSensorWrapper for temperature, humidity, pressure, and dew-point sensors.
Manages initialisation, periodic reading, and value aggregation for every temperature-family sensor supported by the device. The specific hardware driver instantiated depends on the part number received in the Gateway configuration.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_temphum – Nested list holding accumulated readings per sensor/parameter.
bme280 – BME280 driver instance for ambient temperature/humidity/pressure.
boxbme280 – BME280 driver instance for box-internal readings.
sht – SHT31 driver instance.
sht_address – I2C address of the active SHT31 sensor.
bme_address – Index into
bme_addfor the active box BME280 address.bme_add – Candidate I2C addresses for the box BME280.
bme_sensor – Whether the primary BME280 address is still valid.
mpl1152 – MPL1152 barometric-pressure driver instance.
- bme280 = None
- boxbme280 = None
- sht = None
- sht_address = 0
- bme_address = 0
- bme_sensor = True
- mpl1152 = None
- initialize(config, init_value)[source]
Initialise all temperature sensors listed in the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single temperature-family sensor by part number.
Creates the appropriate hardware driver, takes an initial reading for each configured parameter, and stores the bootstrap values in
v_temphum.
- getSensorReading(calibrationKeys=None)[source]
Read current values from all initialised temperature sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- putSensorValue(value, calibrationKeys=None)[source]
Flush accumulated readings into the output dict and reset counters.
Optionally triggers the SHT31 heater for humidity-sensor conditioning.
- putInitvalues(value)[source]
Record each sensor’s init status into the shared init-value dict.
- Parameters:
value (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – Mutable dict updated in-place with a
"temp"key containing a list of per-sensor init statuses.- Return type:
<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>
- Returns:
The updated init-value dict.
OzDust – Particulate Matter
OzCO2 – Carbon Dioxide
CO2 sensor wrapper.
Abstracts over CO2 hardware drivers – ELTCO2 and SCD40 – providing a unified interface for carbon dioxide concentration, temperature, and humidity readings through the GenericSensor contract.
- class OzWrapper.OzCO2.OzCO2.OzCO2[source]
Bases:
GenericSensorWrapper for CO2 sensors.
Manages initialisation, periodic reading, and value aggregation for CO2 sensors. Supports ELT CO2 (I2C) and SCD40 (I2C) drivers, selected by the part number in the Gateway configuration.
- Variables:
- initializeSensor(sensor)[source]
Initialise a single CO2 sensor by part number.
Creates the appropriate hardware driver, takes initial readings with retries, and stores bootstrap values in
v_co2.
- findKeyinList(keys, sensor)[source]
Check whether any parameter short-code in the sensor matches the given keys.
- getSensorReading(calibrationKeys=None)[source]
Read current values from all initialised CO2 sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
OzCH4 – Methane
Methane (CH4) sensor wrapper.
Abstracts over the ELT CH4 UART driver to provide a unified interface for methane concentration readings through the GenericSensor contract.
- class OzWrapper.OzCH4.OzCH4.OzCH4[source]
Bases:
GenericSensorWrapper for methane (CH4) sensors.
Manages initialisation, periodic reading, and value aggregation for CH4 sensors using the ELT CH4 UART driver.
- Variables:
- initializeSensor(sensor)[source]
Initialise a single CH4 sensor by part number.
Creates the ELT CH4 UART driver, takes an initial reading, and stores bootstrap values in
v_ch4.
- getSensorReading()[source]
Read current values from all initialised CH4 sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- Return type:
- Returns:
Dict mapping parameter short-codes to their latest readings.
OzCO – Carbon Monoxide
Carbon monoxide (CO) sensor wrapper.
Provides a stub implementation for CO sensor readings through the GenericSensor contract. Currently uses hardcoded test values as the hardware driver has not yet been integrated.
- class OzWrapper.OzCO.OzCO.OzCO[source]
Bases:
GenericSensorWrapper for carbon monoxide (CO) sensors.
Currently a stub implementation with hardcoded values. Designed to be extended with a real CO sensor driver once hardware is available.
- Variables:
sensor_config – List of sensor config dicts from the Gateway.
v_co – Nested list holding accumulated readings per sensor/parameter.
- sensor_config = {}
- v_co = []
- initialize(config)[source]
Initialise all CO sensors listed in the Gateway config.
- Parameters:
config (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – List of sensor configuration dicts from the Gateway.
- Returns:
True (always, as this is a stub implementation).
- initializeSensor(sensor)[source]
Initialise a single CO sensor by part number.
- Parameters:
sensor (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – Single sensor configuration dict containing part number, enable flag, and parameter list.
- Returns:
1 if the sensor was initialised successfully.
- getSensorReading()[source]
Read current values from all initialised CO sensors.
Accumulates values for later averaging and returns real-time data.
- Returns:
Dict mapping parameter short-codes to their latest readings.
- putSensorValue(value)[source]
Compute averages and flush CO readings into the output dict.
Applies sensitivity and correction offsets to the averaged value.
- Parameters:
value (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – Mutable output dict to populate with averaged readings.
- Return type:
<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>
- Returns:
The updated output dict.
Meteorological
OzWind – Wind Speed & Direction
Wind speed, direction, and gust sensor wrapper.
Communicates with a SAMD-based co-processor over UART (via the OzLan driver) to read wind direction, wind speed, and wind gust measurements through the GenericSensor contract.
- class OzWrapper.OzWind.OzWind.OzWind[source]
Bases:
GenericSensorWrapper for wind sensors communicating via a SAMD co-processor.
Reads wind direction, wind speed, and optionally wind gust from a SAMD-based board over serial. Includes spike filtering to reject implausible jumps in consecutive readings.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_wind – Nested list holding wind reading arrays per sensor.
wind_old – Previous wind reading used for spike filtering.
wind_port – OzLan serial port instance for SAMD communication.
speed_threshold – Maximum acceptable speed jump between consecutive reads.
dir_threshold – Maximum acceptable direction jump between consecutive reads.
- wind_old = None
- speed_threshold = 10
- dir_threshold = 10
- is_valid_wind(wind_old, wind_new)[source]
Validate a new wind reading against the previous one using thresholds.
Rejects readings where both speed and direction jump exceed their respective thresholds simultaneously, which indicates a sensor glitch.
- Parameters:
wind_old – Previous wind reading as a list [direction, speed, …].
wind_new – New wind reading as a list [direction, speed, …].
- Returns:
True if the new reading is plausible, False if it should be rejected.
- initializeSensor(sensor)[source]
Initialise a single wind sensor by part number.
Opens the serial connection to the SAMD co-processor, configures the wind measurement type, and takes an initial reading.
- initializeWind(sensor)[source]
Open the serial connection to the SAMD and verify sensor liveness.
Sends a configuration command followed by a liveness check.
- getSensorReading()[source]
Trigger a wind reading from all initialised sensors.
This method does not return data directly; values are collected in
putSensorValue.- Return type:
- putSensorValue(value)[source]
Read final wind values and populate the output dict.
Applies spike filtering against the previous reading; substitutes zeroes if the new reading is rejected.
OzRain – Rainfall
Rainfall sensor wrapper.
Communicates with a SAMD-based co-processor over UART (via the OzLan driver) to read tipping-bucket rain gauge counts and compute rainfall amounts through the GenericSensor contract.
- class OzWrapper.OzRain.OzRain.OzRain[source]
Bases:
GenericSensorWrapper for rainfall sensors via a SAMD co-processor.
Configures the rain gauge GPIO on the SAMD, reads accumulated tip counts, and converts them to rainfall amounts.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_rain – Nested list holding accumulated readings per sensor.
rain_port – OzLan serial port instance for SAMD communication.
- initialize(config, init_value)[source]
Initialise all rainfall sensors listed in the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single rainfall sensor by part number.
Opens the serial connection to the SAMD and sends the rain gauge GPIO configuration command.
- getSensorReading()[source]
Trigger a rain reading from all initialised sensors.
This method does not return data directly; values are collected in
putSensorValue.- Return type:
- putSensorValue(value)[source]
Read final rainfall values and populate the output dict.
Applies sensitivity and correction offsets to the raw rain count.
OzFlood – Flood Level
Flood level sensor wrapper.
Abstracts over flood-level hardware drivers – Flood (I2C ultrasonic) and FloodUART (UART ultrasonic) – providing a unified interface for water-level distance measurements through the GenericSensor contract.
- class OzWrapper.OzFlood.OzFlood.OzFlood[source]
Bases:
GenericSensorWrapper for flood-level distance sensors.
Manages initialisation, periodic reading, and value aggregation for ultrasonic flood-level sensors (I2C and UART variants).
- Variables:
flood_driver – Flood I2C driver instance, or None.
flood_UARTport – FloodUART driver instance, or None.
configuration (
dict) – List of sensor config dicts from the Gateway.v_flood (
list) – Nested list holding accumulated readings per sensor/parameter.s_flood (
list) – Supplementary flood state list.
- flood_driver = None
- flood_UARTport = None
- initializeSensor(sensor)[source]
Initialise a single flood sensor by part number.
Creates the appropriate driver (I2C or UART), takes an initial reading, and stores bootstrap values in
v_flood.
- getSensorReading()[source]
Read current flood levels from all initialised sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- Return type:
- Returns:
Dict mapping parameter short-codes to their latest readings.
- putSensorValue(value)[source]
Flush accumulated flood readings into the output dict and reset counters.
OzSoil – Soil Moisture
Soil sensor wrapper.
Abstracts over multiple soil sensor drivers – JXBS3001, SEN0600, and NIUBOL (8-in-1 and 3-in-1) – providing a unified interface for soil pH, moisture, temperature, electrical conductivity, nitrogen, phosphorus, and potassium readings through the GenericSensor contract.
- class OzWrapper.OzSoil.OzSoil.OzSoil[source]
Bases:
GenericSensorWrapper for soil sensors (pH, moisture, temperature, EC, NPK).
Manages initialisation, periodic reading, and value aggregation for Modbus-based soil sensors connected via UART.
- Variables:
jxbs – JXBS3001 Modbus soil sensor driver instance.
configuration – List of sensor config dicts from the Gateway.
v_soil – Nested list holding accumulated readings per sensor/parameter.
- jxbs = None
- initializeSensor(sensor)[source]
Initialise a single soil sensor by part number.
Creates the appropriate Modbus driver, takes initial readings for each configured parameter, and stores bootstrap values in
v_soil.
- getSoil(partNo, pm)[source]
Read a soil measurement from the correct driver.
- Parameter mapping for configuration keys:
so1 – pH, so2 – Soil Moisture (%), so3 – Soil Temperature (C), so4 – Electrical Conductivity (uS/cm), so5 – Nitrogen Content (mg/kg), so6 – Phosphorus Content (mg/kg), so7 – Potassium Content (mg/kg).
- Parameters:
- Returns:
The measured value, or None if unsupported.
CONTEXT: KEY USED IN CONFIGURATION FILES: so1-pH so2-Soil Moisture (%) so3-Soil Temperature (°C) so4-Electrical Conductivity (µS/cm) so5-Nitrogen Content (mg/kg) so6-Phosphorus Content (mg/kg) so7-Potassium Content (mg/kg)
- getSensorReading()[source]
Read current values from all initialised soil sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- Return type:
- Returns:
Dict mapping parameter short-codes to their latest readings.
OzSurface – Surface Temperature
Surface temperature sensor wrapper.
Communicates with a SAMD-based co-processor over UART (via the OzLan driver) to read surface temperature measurements through the GenericSensor contract.
- class OzWrapper.OzSurface.OzSurface.OzSurface[source]
Bases:
GenericSensorWrapper for surface temperature sensors via a SAMD co-processor.
Reads surface temperature from a SAMD-connected probe through serial JSON commands.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_surface – Nested list holding surface temperature readings.
surface_port – OzLan serial port instance for SAMD communication.
- initialize(config, init_value)[source]
Initialise all surface temperature sensors from the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single surface temperature sensor by part number.
Opens the serial connection to the SAMD and takes an initial reading.
- initializeSurface(sensor)[source]
Open the serial connection to the SAMD and verify sensor liveness.
Sends a configuration command followed by a liveness check.
- getSensorReading()[source]
Trigger a surface temperature reading from all initialised sensors.
- Return type:
Light & Noise
OzUVLight – UV Light
UV light, visible light, IR, and solar radiation sensor wrapper.
Abstracts over multiple light sensor drivers – TSL2591, VEML6070, Si1133, Si1147, LTR390, and RikaPyro – providing a unified interface for lux, UV index, visible light, infrared, and solar irradiance readings through the GenericSensor contract.
- class OzWrapper.OzUVLight.OzUVLight.OzUVLight[source]
Bases:
GenericSensorWrapper for UV, visible light, IR, and solar radiation sensors.
Manages initialisation, periodic reading, and value aggregation for multiple light sensor ICs. The specific driver instantiated depends on the part number in the Gateway configuration.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_uvlight – Nested list holding accumulated readings per sensor/parameter.
light – TSL2591 visible-light driver instance.
uv – VEML6070 UVA driver instance.
uv_si1133 – Si1133 UV driver instance.
uv_si1147 – Si1147 multi-spectrum driver instance.
uv_ltr390 – LTR390 UV/ambient-light driver instance.
rika_pyro – RikaPyro solar pyranometer driver instance.
light_full – Cached full-spectrum reading from TSL2591.
- light = None
- uv = None
- uv_si1133 = None
- uv_si1147 = None
- uv_ltr390 = None
- rika_pyro = None
- light_full = None
- initialize(config, init_value)[source]
Initialise all UV/light sensors listed in the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single UV/light sensor by part number.
Creates the appropriate hardware driver, configures gain/timing, takes initial readings with retries, and stores bootstrap values in
v_uvlight.
- getSensorReading()[source]
Read current values from all initialised UV/light sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- Return type:
- Returns:
Dict mapping parameter short-codes to their latest readings.
- getUVLight(partNo, pm)[source]
Dispatch a UV/light reading to the appropriate sub-method.
Routes to
getLightfor TSL2591 (part 32),rika_pyrofor pyranometer (part 37), orgetUVfor all other UV/light sensors.
OzVisible – Visible Light
Visible light sensor wrapper.
Communicates with a SAMD-based co-processor over UART (via the OzLan driver) to read ambient visible-light intensity measurements through the GenericSensor contract.
- class OzWrapper.OzVisible.OzVisible.OzVisible[source]
Bases:
GenericSensorWrapper for visible-light sensors via a SAMD co-processor.
Reads ambient visible-light intensity from a SAMD-connected sensor through serial JSON commands.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_visible – Nested list holding visible-light readings.
visible_port – OzLan serial port instance for SAMD communication.
- initialize(config, init_value)[source]
Initialise all visible-light sensors listed in the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single visible-light sensor by part number.
Opens the serial connection to the SAMD and takes an initial reading.
- initializeVisible(sensor)[source]
Open the serial connection to the SAMD and verify sensor liveness.
- getSensorReading()[source]
Trigger a visible-light reading from all initialised sensors.
- Return type:
OzNoise – Noise Level
Noise level sensor wrapper.
Communicates with a SAMD-based co-processor over UART (via the OzLan driver) to read ambient noise-level measurements (average, max, min dB) through the GenericSensor contract.
- class OzWrapper.OzNoise.OzNoise.OzNoise[source]
Bases:
GenericSensorWrapper for noise-level sensors via a SAMD co-processor.
Reads average, maximum, and minimum noise levels (dB) from a SAMD-connected microphone sensor through serial JSON commands.
- Variables:
configuration – List of sensor config dicts from the Gateway.
v_noise – Nested list holding noise reading arrays per sensor.
noise_port – OzLan serial port instance for SAMD communication.
debug – Whether debug mode is active for raw SAMD readings.
- initializeSensor(sensor)[source]
Initialise a single noise sensor by part number.
Opens the serial connection to the SAMD, sends the noise configuration, and takes an initial reading.
- initializeNoise(sensor)[source]
Open the serial connection to the SAMD and verify sensor liveness.
Sends a noise configuration command followed by a liveness check.
- getSensorReading()[source]
Trigger a noise reading from all initialised sensors.
This method does not return data directly; values are collected in
putSensorValue.- Return type:
OzLightning – Lightning Detection
Lightning detection sensor wrapper.
Abstracts over the AS3935 lightning detector IC (via I2C) to provide a unified interface for lightning strike count, estimated distance, and disturber count readings through the GenericSensor contract.
- class OzWrapper.OzLightning.OzLightning.OzLightning[source]
Bases:
GenericSensorWrapper for the AS3935 lightning detection sensor.
Manages initialisation, periodic reading, and value aggregation for lightning strike count, estimated distance, and disturber detection.
- Variables:
uv_as3935 – AS3935 I2C driver instance, or None if not configured.
configuration – List of sensor config dicts from the Gateway.
v_uvlight – Nested list holding accumulated readings per sensor/parameter.
- uv_as3935 = None
- initialize(config, init_value)[source]
Initialise all lightning sensors listed in the Gateway config.
- initializeSensor(sensor)[source]
Initialise a single lightning sensor by part number.
Creates the AS3935 I2C driver, takes initial readings with retries, and stores bootstrap values in
v_uvlight.
- getSensorReading()[source]
Read current lightning data from all initialised sensors.
Applies sensitivity and correction offsets, accumulates values for later averaging, and returns real-time data keyed by short-code.
- Return type:
- Returns:
Dict mapping parameter short-codes to their latest readings.
- putSensorValue(value)[source]
Flush the last accumulated lightning readings and clear counters.
Clears the AS3935 strike/disturber counters after flushing.
- clearData()[source]
Reset the AS3935 strike count, disturber count, and distance list.
- Return type:
System & Infrastructure
OzSystem – System Monitoring
System monitoring wrapper for CPU temperature, disk usage, and GSM modem status.
Provides access to host-level diagnostics (CPU thermal readings, storage metrics) and cellular modem information (signal strength, SIM details) through the GenericSensor interface.
- class OzWrapper.OzSystem.OzSystem.OzSystem[source]
Bases:
GenericSensorWrapper for system-level monitoring: CPU, storage, and GSM modem.
Reads CPU temperature (enabling/disabling the cooling fan as needed), disk usage statistics, and cellular modem signal quality.
- Variables:
gsmModem – QuectelModem instance for cellular communication, or None.
MCP – MCP230XX GPIO expander used for fan control, or None.
CPU_TEMP_THRESHOLD – Temperature in Celsius above which the CPU fan activates.
CPU_FAN – GPIO pin number for the CPU cooling fan.
mcp_flag – Whether the MCP GPIO expander is available.
modem_port – Serial port path for the Quectel modem.
modem_baud – Baud rate for the modem serial connection.
device_space_cmd – Shell command used to query disk space.
configuration – Sensor configuration list from the Gateway.
v_system – Accumulated system reading values per sensor/parameter.
- gsmModem = None
- MCP = None
- CPU_TEMP_THRESHOLD = 35
- CPU_FAN = 6
- mcp_flag = True
- modem_port = '/dev/ttyUSB2'
- modem_baud = 115200
- device_space_cmd = 'df ~ -hP'
- __init__()[source]
Initialize OzSystem with empty configuration and value storage.
- Return type:
None
- initialize(config, init_value, mcpFlag)[source]
Initialize system sensors (CPU stats and/or GSM modem).
- Parameters:
- Return type:
- Returns:
True if all configured sensors initialized successfully, False otherwise.
- getSensorReading()[source]
Collect a single round of system sensor readings.
- Return type:
- Returns:
Dict mapping send-codes to their current values.
- putSensorValue(value)[source]
Aggregate accumulated readings and merge them into the output payload.
- putInitvalues(value)[source]
Add SIM initialization details to the init payload.
- Parameters:
value (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – Shared init payload dict.
- Return type:
<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>
- Returns:
The updated init payload with a ‘sim’ key containing SIM details.
OzBattery – Battery Management
Battery and fuel gauge monitoring wrapper.
Reads voltage, current, and state-of-charge from the MAX17261 fuel gauge IC over I2C, providing battery health telemetry for solar-powered deployments.
- class OzWrapper.OzBattery.OzBattery.OzBattery[source]
Bases:
GenericSensorWrapper for MAX17261 fuel gauge battery monitoring.
Reads instantaneous voltage, current, and state-of-charge from the MAX17261 IC and accumulates time-series values for averaging.
- Variables:
configuration (
dict) – Sensor configuration list from the Gateway.v_battery (
list) – Nested list of per-sensor, per-parameter accumulated values.battery – MAX17261 driver instance, or None before initialization.
debug (
bool) – Whether debug logging is enabled for this sensor.res (
float) – Sense resistor value in ohms for current measurement.resFlag – Whether a custom sense resistor value was provided.
- __init__()[source]
Initialize OzBattery with default configuration and empty accumulators.
- Return type:
None
- initialize(config, init_value)[source]
Initialize the battery fuel gauge sensor from Gateway configuration.
- Parameters:
config (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – List of sensor configuration dicts from the Gateway.
init_value (
dict) – Dict to populate with initialization status flags.
- Return type:
- Returns:
True if at least one battery sensor initialized successfully.
- initializeSensor(sensor)[source]
Initialize a single MAX17261 fuel gauge and take initial readings.
- getSensorReading()[source]
Read current battery values and accumulate them for averaging.
- Return type:
- Returns:
Dict mapping send-codes to their latest calibrated values.
OzError – Error Tracking
Sensor data filtering and aggregation wrapper.
Provides a configurable pipeline of range, delta, statistical, and low-pass filters followed by aggregation functions (average, energy-average, vector wind) to clean raw sensor time-series before publication.
- class OzWrapper.OzError.OzError.OzError[source]
Bases:
objectSensor data quality filter and aggregation engine.
Applies a configurable chain of filters (range, delta, statistical, low-pass) to raw sensor readings, then aggregates the cleaned values using parameter-specific strategies (arithmetic mean, energy dB average, vector wind, latest GPS, min/max).
- Variables:
DEBUG – Class-level debug flag.
counter – Warm-up countdown; filters are bypassed until this reaches 0.
publish_interval – Seconds between publish cycles (used for warm-up display).
debug_mode – Instance-level verbose logging toggle.
low_pass_cache_values (
dict) – Per-key cache for the exponential moving average filter.cache_filtered_values (
dict) – Per-key cache of the most recent filtered series.old_values (
dict) – Per-key cache of the last aggregated value (fallback on empty series).filter_length (
int) – Number of samples required before low-pass filtering activates.
- DEBUG = False
- __init__()[source]
Initialize OzError with default filter config for all known parameters.
- Return type:
None
- putSensorValue(values, calibration=False)[source]
Filter and aggregate raw sensor value lists into scalar outputs.
- Parameters:
- Return type:
- Returns:
The updated dict with each key replaced by its aggregated scalar value, plus optional confidence keys (
<key>_cf) when outliers were removed.
- range_filter(key, values)[source]
Remove values outside the configured min/max range for a parameter.
- delta_filter(key, values)[source]
Remove spike values that exceed the configured delta from the previous reading.
- statistical_filter(key, values)[source]
Remove outliers beyond a configurable number of standard deviations.
- low_pass_filter(key, values, alpha=0.15)[source]
Apply exponential moving average (low-pass) filter to smooth sensor readings. Reduces high-frequency noise while preserving signal trends.
Formula: filtered[n] = α × input[n] + (1 - α) × filtered[n-1]
- Parameters:
- Returns:
- (remove_count, filtered_values)
remove_count: Always 0 (low-pass doesn’t remove values)
filtered_values: Smoothed values
- Return type:
Note
Requires accumulating filter_length values before filtering begins. During accumulation, returns original values unchanged.
- energy_average(key)[source]
Compute acoustically correct energy average for decibel values.
Uses the formula: 10 * log10(mean(10^(dB/10))) with numerical stability via max-value subtraction.
- vector_direction(key)[source]
Compute vector-averaged direction from directional data and related magnitudes.
Uses U/V component decomposition for proper circular averaging of wind direction paired with wind speed magnitudes.
- latest_value(key)[source]
Return the most recent value from the filtered cache (used for GPS coordinates).
OzGPS – GPS Location
GPS location wrapper for Quectel modem GNSS receivers.
Reads latitude, longitude, and satellite count from a Quectel modem’s GPS subsystem, and optionally synchronizes the device RTC with GPS time.
- class OzWrapper.OzGPS.OzGPS.OzGPSParam[source]
Bases:
objectContainer for a single GPS module’s configuration and driver reference.
- Variables:
partNo – Part number identifying the GPS module type.
configuration_port – Serial port for modem AT commands.
gps_port – Serial port for NMEA GPS data.
baud – Baud rate for the GPS serial connection.
gps_driver – QuectelGPS driver instance, or None before initialization.
old_data – Cache of previous GPS readings for fallback.
- Parameters:
- gps_driver = None
- partNo = 0
- gps_port = '/dev/ttyUSB1'
- configuration_port = '/dev/ttyUSB2'
- baud = 115200
- class OzWrapper.OzGPS.OzGPS.OzGPS[source]
Bases:
objectGPS location wrapper managing Quectel GNSS modules.
Reads latitude, longitude, and satellite count from GPS NMEA data, accumulates time-series values, and optionally syncs the hardware RTC.
- Variables:
gps_poll – Whether to actively poll GPS on each reading cycle.
lat – Last known latitude in decimal degrees.
lon – Last known longitude in decimal degrees.
put_sensor – Whether GPS data should be included in published payloads.
xone – xOne assisted-GPS enable flag.
xpath – URL path for xTRA ephemeris data download.
xname – Filename of the xTRA ephemeris binary.
v_gps – Accumulated GPS reading values per sensor/parameter.
configuration – GPS sensor configuration list from the Gateway.
s_gps – List of OzGPSParam instances (one per configured GPS module).
- gps_poll = True
- lat = 0.0
- lon = 0.0
- put_sensor = 0
- xone = 0
- xpath = 'http://xtrapath6.izatcloud.net/'
- xname = 'xtra3grc.bin'
- getSensorReading()[source]
Poll all GPS modules and accumulate lat/lon/satellite readings.
- Return type:
- Returns:
Dict mapping send-codes to their latest GPS values.
OzRGB – LED Indicator
RGB LED indicator wrapper for NeoPixel status display.
Drives a NeoPixel LED strip to indicate device status (network connectivity, data sending, errors) through color and blink/fade patterns, and optionally shows AQI-based beacon colors on remaining LEDs.
- OzWrapper.OzRGB.OzRGB.hex_to_rgb(hex_code)[source]
Convert a 6-character hex color code to an (R, G, B) tuple.
- OzWrapper.OzRGB.OzRGB.get_color_from_value(value)[source]
Look up the beacon hex color for a given AQI value.
- class OzWrapper.OzRGB.OzRGB.Magic[source]
Bases:
objectLED animation engine providing fade and blink patterns for NeoPixel strips.
- Variables:
brightness – Current brightness level (0.0 to 1.0).
min_bright – Minimum brightness counter value for fade animations.
max_bright – Maximum brightness counter value for fade animations.
bright_divider – Divisor to convert counter to NeoPixel brightness (0.0-1.0).
fadInDelay – Milliseconds between brightness increments during fade-in.
fadeOutWait – Milliseconds between brightness decrements during fade-out.
pixels – NeoPixel strip instance being controlled.
RISING – Direction constant for increasing brightness.
FALLING – Direction constant for decreasing brightness.
blink_delay – Milliseconds between blink toggles.
blink_direction – Current blink phase (RISING or FALLING).
- Parameters:
pixels (
NeoPixel)
- brightness = 0
- min_bright = 1
- max_bright = 100
- bright_divider = 100
- fadInDelay = 20
- fadeOutWait = 20
- counter_brightness = 0
- RISING = 1
- FALLING = -1
- blink_direction = 1
- prev_blinking = 0
- __init__(pixels)[source]
Initialize the animation engine with a NeoPixel strip.
- Parameters:
pixels (
NeoPixel) – NeoPixel strip instance to control.- Return type:
None
- pixels = None
- blink_delay = 60
- setFadeProperty(brightness=0, min_bright=1, max_bright=100, bright_divider=100, fadInDelay=20, fadeOutWait=10)[source]
Configure fade animation properties.
- Parameters:
brightness (
int) – Initial brightness counter value.min_bright (
int) – Minimum brightness counter for fade range.max_bright (
int) – Maximum brightness counter for fade range.bright_divider (
int) – Divisor to convert counter to NeoPixel brightness.fadInDelay (
int) – Milliseconds between fade-in steps.fadeOutWait (
int) – Milliseconds between fade-out steps.
- Return type:
Communication
OzSocket – WebSocket
WebSocket communication wrapper using Socket.IO.
Manages bidirectional real-time communication with the Gateway container, receiving MQTT data and calibration keys, broadcasting sensor payloads to downstream queues (Modbus, HMI, Display), and emitting raw device data.
- class OzWrapper.OzSocket.OzSocket.OzSocket[source]
Bases:
objectSocket.IO client for real-time data exchange with the Gateway.
Connects to the Gateway WebSocket endpoint, receives MQTT sensor data and calibration commands, fans out payloads to local consumer queues, and emits raw device data back to the server.
- Variables:
configuration (
dict) – Socket configuration dict from the Gateway.web_socket_url (
str) – WebSocket endpoint URL.ignoring_keys (
list[str]) – Telemetry keys excluded from negative-value clamping.calibration_keys (
list[str]) – Keys requiring calibration before processing.sending_queue (
list[Queue]) – List of Queues for broadcasting data to downstream consumers.receiving_queue (
list[Queue]) – List of Queues for incoming MQTT data.mqtt_send_queue (
Queue|None) – Queue for outgoing MQTT data to emit via socket.socket (
Client) – Socket.IO client instance with auto-reconnection.need_data_publish (
Event) – Threading event controlling data publish gating.debug_mode (
bool) – Whether verbose debug logging is enabled.
- __init__()[source]
Initialize the socket client, configure default endpoints, and set up key filters.
- Variables:
socket (socketio.Client) – Socket.IO client configured with reconnection and timeout options.
web_socket_url (str) – WebSocket endpoint URL loaded from the WS_URL environment variable or defaulting to http://redis.local:8080.
ignoring_keys (list[str]) – Telemetry keys that should be ignored when handling socket messages.
calibration_keys (list[str]) – Telemetry keys that require calibration before processing.
sending_queue (list[queue.Queue]) – Collection of queues used to broadcast incoming messages across consumers.
- Return type:
None
- setup(socket_config, sending_queue, receiving_queue, mqtt_send_queue, need_data_publish)[source]
Configure queues, register Socket.IO callbacks, and connect to the server.
- Parameters:
socket_config (
dict) – Configuration dict with socket settings.sending_queue (
list[Queue]) – List of Queues to broadcast received data to consumers.receiving_queue (
list[Queue]) – List of Queues for incoming MQTT data.mqtt_send_queue (
Queue) – Queue for outgoing data to emit via socket.need_data_publish (
Event) – Event flag controlling whether data is published.
- Return type:
- loop()[source]
Start a background thread to emit queued data and wait on the socket connection.
- Return type:
- socket_callbacks()[source]
Register all Socket.IO event handlers (connect, disconnect, data listeners).
- Return type:
- run(socket_config, sending_queue, receiving_queue, mqtt_send_queue, need_data_publish)[source]
Entry point: set up the socket and start the event loop if enabled.
- Parameters:
socket_config (
dict) – Configuration dict with ‘en’ enable flag.sending_queue (
list[Queue]) – List of Queues for downstream consumers.receiving_queue (
list[Queue]) – List of Queues for incoming MQTT data.mqtt_send_queue (
Queue) – Queue for outgoing data emission.need_data_publish (
Event) – Event flag for data publish gating.
- Return type:
OzModbus – Modbus
Modbus RTU/TCP server wrapper for exposing sensor data as holding registers.
Maps sensor telemetry keys to Modbus holding register addresses and serves them over RTU (serial) and/or TCP transports using PyModbus, enabling integration with SCADA and PLC systems.
- class OzWrapper.OzModbus.OzModbus.OzModbus[source]
Bases:
objectModbus server wrapper mapping sensor keys to holding registers.
Receives sensor payloads from a queue, writes values into a Modbus register context, and serves them via RTU and/or TCP server threads.
- Variables:
pymodbus – PyModbus driver instance managing the server context.
slaveId – Modbus slave/unit ID for this device.
modbus_context – Server data context holding register values.
holding_register – Function code for holding registers (3).
isRealtime – Whether to process only realtime data payloads.
payloaddata – Latest sensor payload received from the queue.
modbus_keys (
dict[str,int]) – Mapping of sensor send-codes to register addresses.can_negative (
list[str]) – List of send-codes allowed to have negative values.
- pymodbus = None
- slaveId = 0
- modbus_context = None
- holding_register = 3
- isRealtime = 0
- payloaddata = None
- __init__()[source]
Initialize OzModbus with the default register map and negative-value whitelist.
- Return type:
None
- setup(modbusConfig, modbus_queue)[source]
Configure and start the Modbus RTU and/or TCP server(s).
Parses serial port, baud rate, parity, server mode, host/port, and slave ID from the configuration, builds the register context, and starts server threads.
OzLora – LoRa Radio
LoRa communication wrapper for transmitting sensor data over LoRaWAN.
Encodes sensor telemetry into binary LoRa payloads and transmits them via Melange, OTTA, or LORA-E5 modules, supporting both ABP and OTAA activation modes with configurable regional settings.
- class OzWrapper.OzLora.OzLora.OzLora[source]
Bases:
objectLoRaWAN communication wrapper supporting multiple LoRa module types.
Manages LoRaWAN key provisioning, binary payload encoding via struct, dual-buffer transmission, and downlink command processing (including remote reboot).
- Variables:
module – LoRa driver instance (Melange, OTTA, or LORAE5), or None.
appkey – OTAA application key.
network_key – ABP network session key.
app_session_key – ABP application session key.
dev_addr – ABP device address.
lora_class – LoRaWAN device class (A, B, or C).
lora_mode – Activation mode (ABP or OTAA).
lora_region – Regional frequency plan identifier.
isRealtime – Whether to transmit only realtime data payloads.
modulePart – Module type selector (0 = Melange, 1 = OTTA, 2 = LORA-E5).
lora_keys – Primary payload register map (send-code to [offset, byte-length]).
lora_keys_2 – Secondary payload register map.
lora_buffer – Primary binary transmit buffer.
lora_buffer_2 – Secondary binary transmit buffer.
- module = None
- __init__()[source]
Initialize OzLora with default keys, buffers, and register maps.
- Return type:
None
- setup(loraConfig)[source]
Configure the LoRa module with keys, port settings, and regional parameters.
- convert(val, points=2)[source]
Pack a sensor value into a binary byte list for LoRa transmission.
Uses struct packing with network byte order. Supports 1-byte unsigned, 2-byte unsigned/signed (x10 scaling), and 4-byte float/unsigned int.
- rebootGSM(gsm_port='/dev/ttyUSB3')[source]
Reboot the GSM modem via AT command and wait for it to come back online.
- rebootSystem()[source]
Reboot the entire device by resetting the GSM modem and triggering SAMD watchdog.
- Return type:
OzDisplay – E-Paper Display
E-paper and 7-segment display wrapper for showing sensor readings.
Drives TM1637 (4-digit 7-segment) or TM1638 (8-digit with LEDs) displays to show real-time sensor values with unit indicator LEDs, supporting multi-parameter cycling.
- class OzWrapper.OzDisplay.OzDisplay.OzDisplay[source]
Bases:
objectWrapper for TM1637/TM1638 7-segment displays with unit indicator LEDs.
Shows sensor readings on a 7-segment display, cycling through multiple parameters with configurable decimal precision and unit LED indicators.
- Variables:
display – TM1637Decimal or TM1638 driver instance, or None before setup.
payloaddata – Latest sensor payload received from the queue.
CLK – GPIO clock pin for the display.
DIO – GPIO data pin for the display.
STB – GPIO strobe pin for TM1638 displays.
MCP – MCP230XX GPIO expander for unit LEDs (TM1637 mode), or None.
sTime – Display refresh timeout in seconds.
displayParam – Currently displayed parameter send-code.
displayUnit – Currently displayed unit string.
displayCount – Index into the multi-parameter cycle list.
isRealtime – Whether to process only realtime data payloads.
parameters (
list) – Display parameter configuration list.multiParam (
list) – List of send-codes to cycle through on the display.
- display = None
- payloaddata = None
- CLK = 21
- DIO = 20
- STB = 3
- MCP = None
- sTime = 10
- displayParam = None
- displayUnit = None
- displayCount = -1
- isRealtime = 0
- __init__()[source]
Initialize OzDisplay with default pin assignments and unit mappings.
- Return type:
None
- updateLed()[source]
Update the unit indicator LED based on the currently displayed parameter.
- Return type:
OzHMI – 7-Segment Display
HMI (Human-Machine Interface) display wrapper for Nextion/UART touch screens.
Drives a Nextion-style UART HMI display to show sensor parameter names, values, and units on multiple pages, along with status icons for WiFi, GSM, GPS, and battery. Also queries the network manager for connectivity details.
- class OzWrapper.OzHMI.OzHMI.OzHMI[source]
Bases:
objectHMI display wrapper for Nextion-style UART touch screens.
Receives sensor payloads from a queue, maps send-codes to human-readable parameter labels and units, and writes formatted values to the HMI driver. Also manages status icons (WiFi, GSM, GPS, battery) and settings pages.
- Variables:
hmi – HMI driver instance, or None before setup.
deviceId – Device identifier shown on the HMI about page.
hmi_port – UART serial port path for the HMI display.
hmi_baud – Baud rate for HMI serial communication.
timezone – Timezone string for timestamp display.
hmi_key_Param – Mapping of send-codes to display parameter labels.
hmi_key_Unit – Mapping of send-codes to display unit strings.
hmi_key_fc – Mapping of send-codes to conversion factors.
isRealtime – Whether to process only realtime data payloads.
network – Network instance for internet connectivity checks.
Sample Data frame of Oizom V6 device: {‘d’: {‘temp’: 0, ‘hum’: 0, ‘hum_cf’: 0, ‘g51’: 342.09, ‘g55’: 347.92, ‘g61’: 345.15, ‘g65’: 359.71, ‘g81’: 352.66, ‘g85’: 357.04, ‘g21’: 331.56, ‘g25’: 348.03, ‘s1’: 55.02, ‘leq’: 49.45, ‘lmax’: 60.5, ‘lmin’: 44.8, ‘wd’: 339, ‘ws’: 1.841428518, ‘rain’: 0, ‘t’: 1691524500}, ‘deviceId’: ‘P1950’, ‘deviceType’: ‘POLLUDRON_PRO’} Standard Oizom Key Units: {“g1 “: “ppm”, “g2 “: “mg/m3”, “g3 “: “ug/m3”, “g4 “: “ug/m3”, “g5 “: “ug/m3”, “g6 “: “ug/m3”, “g7 “: “ug/m3”, “g8 “: “ug/m3”, “g9 “: “%”, “v1 “: “ppb”, “v2 “: “ppb”, “v3 “: “ppb”, “v4 “: “ppm”, “v5 “: “ppb”, “v6 “: “ppb”, “p1 “: “ug/m3”, “p2 “: “ug/m3”, “p3 “: “ug/m3”, “p4 “: “ug/m3”, “temp “: “Celsius”, “hum “: “%”, “t “: “Seconds”, “leq “: “dB”, “lmin “: “dB”, “lmax “: “dB”, “rain “: “mm”, “light “: “Lux”, “flood “: “mm”, “uv “: “Index”, “ws “: “m/s”, “wd “: “Degree”, “pr “: “HPa”} Standard Oizom Key Parameters: {“g1” : “CO2”, “g2” : “CO”, “g3” : “NO2”, “g4” : “NH3”, “g5” : “O3”, “g6” : “H2S”, “g7” : “NO”, “g8” : “SO2”, “g9” : “O2”, “v1” : “Cl2”, “v2” : “TVOC”, “v3” : “CH2O”, “v4” : “CH4”, “v5” : “CH3SH”, “v6” : “C2H4”, “p1” : “PM2”, “p2” : “PM10”, “p3” : “PM1”, “p4” : “PM100”, “temp” : “Temperature”, “hum” : “Humidity”, “t” : “TimeStamp”, “leq” : “NoiseAverage”, “lmin” : “MinNoise”, “lmax” : “MaxNoise”, “rain” : “RainFall”, “light” : “VisibleLight”, “flood” : “FloodLevel”, “uv” : “UVIndex”, “ws” : “WindSpeed”, “wd” : “WindDirection”, “pr” : “Pressure”}
- fc = 1
CO2 - ppm All Gas - ppb Dust - ug/m3
O2 - %
Temp - deg C Hum - % Pressure - HPa
Wind Speed - m/s Wind Direction - deg Rain - mm
- deviceId = 'OZTEST001'
- hmi = None
- lastCal = '13/08/2023'
- version = '1.0'
- hmi_port = '/dev/ttyAMA2'
- hmi_baud = 115200
- timezone = 'Asia/Kolkata'
- debug = 0
- heatingInterval = 2
- lat = '23.456789 N'
- lon = '73.456789 N'
- once = True
- nmOnce = True
- url = ''
- response = None
- payloaddata = None
- sTime = 10
- displayCount = -1
- isRealtime = 0
- isInternet = 0
- isCharging = 0
- currentTime = 0
- prevTime = 0
- network = None
- __init__()[source]
Initialize OzHMI with default settings and empty key mappings.
- Return type:
None
- setup(hmiConfig)[source]
Configure the HMI display, build key mappings, and initialize status icons.
Calibration & Special
OzOGS – Odor Gas Sensor
Odor/gas sensor (OGS) allocation wrapper for electrochemical and reference analyzers.
Manages a multiplexed array of gas sensors (ADS122U04, Winsen, Cubic, Semeatech, NevadaNano, HORIBA, Serinus) accessed through UART multiplexer GPIO selection, providing unified read/calibrate/publish for NO2, O3, CO, SO2, H2S, NO, and O2.
- OzWrapper.OzOGS.OzOGS.context_logger = <utils.oizom_logger.OizomLogger object>
201, sendCode: g3 O3: partNo: 203, sendCode: g5 CO: partNo: 202, sendCode: g2 SO2: partNo: 204, sendCode: g8 H2S: partNo: 205, sendCode: g6 NO: partNo: 206, sendCode: g7
- Type:
NO2
- Type:
- class OzWrapper.OzOGS.OzOGS.OzOGSParam[source]
Bases:
objectContainer for a single OGS sensor’s configuration and driver reference.
- Variables:
partNo – Part number identifying the sensor type (101-109).
port – UART serial port path.
baud – Baud rate for the serial connection.
address – Multiplexer channel address within an IC.
ic – Multiplexer IC index (0 or 1).
pga – Programmable gain amplifier setting for ADS122U04.
ogs_port – Sensor driver instance (ADS122U04, WinsenO2, etc.), or None.
- Parameters:
- pga = 0
- ogs_port = None
- partNo = 0
- port = '/dev/ttyAMA0'
- baud = 115200
- address = -1
- ic = -1
- class OzWrapper.OzOGS.OzOGS.OzOGS[source]
Bases:
GenericSensorMultiplexed gas sensor wrapper supporting multiple electrochemical and reference analyzers.
Manages a UART multiplexer (2 ICs x 4 channels) to address up to 8 gas sensors, handling initialization, GPIO-based channel selection, reading, calibration-aware averaging, and payload assembly.
- Variables:
AVERAGE_COUNT – Number of readings to average per cycle.
GPIO_A – GPIO pin A for multiplexer address selection.
GPIO_B – GPIO pin B for multiplexer address selection.
GPIO_ENABLE_1 – GPIO enable pin for multiplexer IC 0.
GPIO_ENABLE_2 – GPIO enable pin for multiplexer IC 1.
SENSOR_PER_IC – Number of sensor channels per multiplexer IC.
configuration – Gas sensor configuration list from the Gateway.
v_ogs – Nested list of per-sensor, per-parameter accumulated values.
p_ogs – List of OzOGSParam instances (one per configured sensor).
- AVERAGE_COUNT = 1
- GPIO_A = 24
- GPIO_B = 25
- GPIO_ENABLE_1 = 27
- GPIO_ENABLE_2 = 17
- SENSOR_PER_IC = 4
- updateTempForADS(sensor)[source]
Append an internal temperature parameter to ADS122U04 sensor config if missing.
- updateTempHumForSemeatech(sensor)[source]
Append temperature and humidity parameters to Semeatech sensor config if missing.
- initialize(config, init_value)[source]
Initialize all configured gas sensors and set up GPIO multiplexer pins.
- initializeSensor(sensor)[source]
Initialize a single gas sensor based on its part number.
Creates the appropriate driver, selects the multiplexer channel, and takes initial readings for each configured parameter.
- Part numbers:
101 = ADS122U04, 102 = Winsen, 103 = Cubic, 104 = Semeatech, 105 = SemeatechA4, 106 = NevadaNano, 107 = HORIBA, 109 = Serinus.
- findKeyinList(keys, sensor_list)[source]
Check if any sensor parameter send-code matches the provided calibration keys.
- getSensorReading(calibrationKeys=None)[source]
Read all initialized gas sensors and accumulate values.
- putSensorValue(value, calibrationKeys=None)[source]
Transfer accumulated gas sensor readings into the output payload and reset.
- putInitvalues(value)[source]
Add OGS sensor initialization flags to the init payload.
- Parameters:
value (<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>) – Shared init payload dict.
- Return type:
<module ‘json’ from ‘/opt/buildhome/.asdf/installs/python/3.12.12/lib/python3.12/json/__init__.py’>
- Returns:
The updated init payload with an ‘ogs’ key listing init statuses.
OzOSP – Outdoor Sensor Package
Oizom Sensor Protocol (OSP) wrapper for Modbus RTU sensor integration.
Reads sensor data from external Modbus RTU slave devices over a shared serial bus, supporting configurable function codes, register addresses, endianness, and multi-register float parsing.
- class OzWrapper.OzOSP.OzOSP.OzOSP[source]
Bases:
GenericSensorModbus RTU client wrapper for reading external sensor slaves.
Creates a shared Modbus RTU serial client and reads holding/input registers from multiple slave devices, applying sensitivity and correction factors to raw register values.
- Variables:
configuration – OSP sensor configuration dict from the Gateway.
client – PyModbus serial client instance, or None before initialization.
OSP_data – Dict of accumulated sensor readings keyed by send-code.
debug – Whether verbose debug logging is enabled.
- initialize(config, init_value)[source]
Initialize the Modbus RTU client and probe all configured slave sensors.
- initializeSensor(sensor)[source]
Probe a Modbus slave sensor by reading all its configured parameters.
- getSensorData(modbus_client, slave_id, config)[source]
Read a single parameter from a Modbus slave register.
- Parameters:
modbus_client – PyModbus client instance.
slave_id – Modbus slave/unit ID.
config – Parameter configuration dict with register, fn_code, count, endian, cr (correction), and se (sensitivity).
- Returns:
Corrected sensor value as float, or None on error.
- getSensorReading(calibrationKeys=[])[source]
Read all configured Modbus slave sensors and accumulate values.
- Parameters:
calibrationKeys – Optional list of send-codes to restrict which sensors are read (empty = read all).
- Return type:
- Returns:
Dict mapping send-codes to their accumulated value lists.
OzAlert – Automation Alerts
Alert and automation wrapper for threshold-based sensor alerts.
Monitors sensor readings against configurable upper/lower thresholds and triggers GPIO outputs (buzzer, light, relay), email/SMS notifications, or MQTT messages when thresholds are breached.
- class OzWrapper.OzAlert.OzAlert.OzAlert[source]
Bases:
objectThreshold-based alert handler for sensor automation.
Evaluates incoming sensor data against configured thresholds and activates the appropriate output channel (GPIO relay, buzzer/light, email, SMS, or MQTT).
- Variables:
output1_pin – GPIO pin number for relay output 1.
output2_pin – GPIO pin number for relay output 2.
buzzer_pin – GPIO pin number for the audible buzzer.
light_pin – GPIO pin number for the alert indicator light.
minInterval – Minimum polling interval (seconds) across all alerts.
alerts (
list[dict[str,Any]]) – List of alert configuration dicts from the Gateway.manager – Manager instance for sending email/SMS via the Gateway.
MCP – MCP230XX I/O expander instance (used when pin >= 100).
mqtt_send_queue (
Queue|None) – Queue for publishing MQTT alert payloads.
- Parameters:
manager (
Manager)
- output1_pin = 19
- output2_pin = 20
- buzzer_pin = 16
- light_pin = 26
- minInterval = 100000
- __init__(manager)[source]
Initialise the OzAlert handler.
- Parameters:
manager (
Manager) – Manager instance used to dispatch email/SMS alerts through the Gateway API.- Return type:
None
- setup(alertConfig)[source]
Configure GPIO pins and load alert rules from the Gateway config.
Sets up output pins (direct GPIO or MCP230XX expander) for buzzer, light, and relay channels, then loads the list of alert rules.
- loop(alertqueue)[source]
Run the alert evaluation loop, blocking on the queue for sensor data.
Continuously reads sensor payloads from the queue, compares each value against its upper/lower thresholds, and triggers the corresponding alert channel. Also handles timed alert resets.
- setAlert(output, status, config=None, data=None, threshold=None, operator=None)[source]
Activate or deactivate an alert on the specified output channel.
- Channel mapping:
0 – relay output 1 (GPIO/MCP) 1 – relay output 2 (GPIO/MCP) 2 – buzzer + light (GPIO/MCP) 3 – email notification via Gateway 4 – SMS notification via Gateway 5 – MQTT message via send queue
- Parameters:
output (
int) – Output channel number (0-5).status (
int) – Desired state (1 = active, 0 = inactive).config (
dict[str,Any] |None) – Alert rule dict (required for email/SMS/MQTT channels).threshold (
int|float|None) – Threshold value that was breached.operator (
str|None) – Comparison operator string (">"or"<").
- Return type: