rpymostat_sensor.sensors.base module

class rpymostat_sensor.sensors.base.BaseSensor[source]

Bases: object

Base class for the interface that all hardware Sensor classes must implement. Any class that implements this interface will be usable to discover and read sensors. Note that classes implementing this must also have a matching entrypoint in order to be discovered.

If the class constructor takes any arguments, they must be documented in Sphinx format in the docstring of the __init__ method.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 31
_abc_registry = <_weakrefset.WeakSet object>
_description = 'Unknown'
get_description()[source]

Return the sensor class’s _description attribute.

Returns:Sensor class’s description
Return type:str
read()[source]

Read all present temperature sensors. Returns a dict of sensor unique IDs (keys) to dicts of sensor information.

Return dict format:

{
    'unique_id_1': {
        'type': 'sensor_type_string',
        'value': 1.234,
        'alias': 'str',
        'extra': ''
    },
    ...
}

Each dict key is a globally-unique sensor ID. Each value is a dict with the following keys:

  • type: (str) sensor type
  • value: (float) current temperature in degress Celsius, or None if
    there is an error reading it.
  • alias: (str) a human-readable alias/name for the sensor, if present
  • extra: (str) any extra information about the sensor
Returns:dict of sensor values and information.
Return type:dict
sensors_present()[source]

Discover all matching sensors on the system. Return True if sensors were discovered, False otherwise. The class should cache information on the discovered sensors in order to read them later.

Returns:whether or not matching sensors are present
Return type:bool