rpymostat_sensor.sensors.owfs module

class rpymostat_sensor.sensors.owfs.OWFS(owfs_path=None)[source]

Bases: rpymostat_sensor.sensors.base.BaseSensor

Sensor class to read OWFS sensors. Currently only tested with DS18S20.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 31
_abc_registry = <_weakrefset.WeakSet object>
_description = 'Dallas Semi 1-Wire Sensors via OneWire FileSystem (OWFS)'
_discover_owfs()[source]

If owfs_path is not specified for OWFS.__init__, attempt to find an OWFS mounted at some of the common paths. If one is found, return the path to it. If not, return None.

Returns:path to OWFS mountpoint or None
_find_sensors()[source]

Find all OWFS temperature sensors present. Return a list of dicts of information about them. Dicts have the format:

Return dict format:

{
    'temp_path': 'absolute path to read temperature from',
    'alias': 'sensor alias, if set',
    'address': 'sensor address',
    'type': 'sensor type'
}

The only required key in the dict is temp_path.

Returns:list of dicts describing present temperature sensors.
Return type:dict
_get_temp_scale(owfs_path)[source]

Read and return the temperature_scale setting in use by OWFS mounted at owfs_path.

Parameters:owfs_path (str) – OWFS mountpoint
Returns:temperature scale in use (‘C’, ‘F’, ‘K’, or ‘R’)
Return type:str
_read_owfs_file(sensor_dir, fname)[source]

Read the contents of a file from OWFS; return None if the file does not exist, or the strip()’ed contents if it does. Really just a helper for cleaner unit testing.

Parameters:
  • sensor_dir (str) – self.owfs_path subdir for the sensor
  • fname (str) – file name/path under sensor_dir
Returns:

stripped content str or None

owfs_paths = ['/run/owfs', '/owfs', '/mnt/owfs', '/var/owfs', '/1wire', '/var/1wire', '/mnt/1wire', '/run/1wire']
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
sensor_dir_re = <_sre.SRE_Pattern object>
sensors_present()[source]

Determine whethere there are OWFS temperature sensors present or not.

Returns:True because it’s always here
Return type:bool