pi_weather.core.managers.stcc4_service module

class pi_weather.core.managers.stcc4_service.STCC4Service[source]

Bases: object

STCC4 sensor service class

__init__()[source]

Constructor function (init)

Return type:

None

static _is_sensor_enabled()[source]

Function to check whether current sensor is enabled or disabled from the docker-compose.yaml

Returns:

True if STCC4 sensor is enabled, False otherwise

Return type:

bool

get_latest()[source]

Function to get the latest sensor reading

Returns:

Latest sensor data read by the sensor

Return type:

LatestSTCC4SensorReading | None

_update_metrics(co2, t, h, sensor_status, et, air_quality)[source]

Function to update Prometheus metrics

Parameters:
  • co2 (float) – CO2 concentration

  • t (float) – Temperature

  • h (float) – Humidity

  • sensor_status (int) – Sensor status

  • et (float) – Event time generated

  • air_quality (int) – Air quality index

Returns:

Nothing

Return type:

None

_save_latest_reading(co2, t, h, sensor_status, et, air_quality)[source]

Function to record/save the latest sensor reading

Parameters:
  • co2 (float) – CO2 concentration

  • t (float) – Temperature

  • h (float) – Humidity

  • sensor_status (int) – Sensor status

  • et (float) – Event time generated

  • air_quality (int) – Air quality index

Returns:

Nothing

Return type:

None

_read_sensor_data()[source]

Function to read sensor data This method will record the latest reading + update Prometheus metrics

Returns:

Nothing

Return type:

None

_log_new_data(co2, t, h, sensor_status, et, air_quality)[source]

Function to correctly log the new data read (regardless the data acquisition mode

Parameters:
  • co2 (float) – CO2 concentration

  • t (float) – Temperature

  • h (float) – Humidity

  • sensor_status (int) – Sensor status

  • et (float) – Event time generated

  • air_quality (int) – Air quality index

Returns:

Nothing

Return type:

None

_on_polling()[source]

Function to be executed within the separate polling thread (target func)

Returns:

Nothing

Return type:

None

start()[source]

Function to start the sensor data capture

Returns:

Nothing

Return type:

None

stop()[source]

Function to stop the sensor data capture

Returns:

Nothing

Return type:

None