Add support for aliased owfs sensors (#6043)
* Support aliased owfs sensors Current implementation does not support OneWire OWFS sensors that are aliased by OWFS alias.txt file: http://owfs.org/index.php?page=aliases Assumption is that folder name == sensor address This change reads the supported families from owfs "family" file and adds both aliased and unaliased sensors. (this approach also skips the "management" folders.. eg simultaenous, bus, alarm, statistics etc. For example when adding "simultaneous" as sensor (it also has "temperature" file) then owfs crashes) * Update onewire.py lint suggested style fixes * Update onewire.py Empty line removed * Update onewire.py comments removedpull/6101/head
parent
a4318c3125
commit
dee4c85c32
|
@ -33,14 +33,22 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
base_dir = config.get(CONF_MOUNT_DIR)
|
||||
sensor_ids = []
|
||||
device_files = []
|
||||
for device_family in DEVICE_FAMILIES:
|
||||
for device_folder in glob(os.path.join(base_dir, device_family +
|
||||
'[.-]*')):
|
||||
sensor_ids.append(os.path.split(device_folder)[1])
|
||||
if base_dir == DEFAULT_MOUNT_DIR:
|
||||
if base_dir == DEFAULT_MOUNT_DIR:
|
||||
for device_family in DEVICE_FAMILIES:
|
||||
for device_folder in glob(os.path.join(base_dir, device_family +
|
||||
'[.-]*')):
|
||||
sensor_ids.append(os.path.split(device_folder)[1])
|
||||
device_files.append(os.path.join(device_folder, 'w1_slave'))
|
||||
else:
|
||||
device_files.append(os.path.join(device_folder, 'temperature'))
|
||||
else:
|
||||
for family_file_path in glob(os.path.join(base_dir, '*', 'family')):
|
||||
family_file = open(family_file_path, "r")
|
||||
family = family_file.read()
|
||||
if family in DEVICE_FAMILIES:
|
||||
sensor_id = os.path.split(
|
||||
os.path.split(family_file_path)[0])[1]
|
||||
sensor_ids.append(sensor_id)
|
||||
device_files.append(os.path.join(
|
||||
os.path.split(family_file_path)[0], 'temperature'))
|
||||
|
||||
if device_files == []:
|
||||
_LOGGER.error('No onewire sensor found. Check if '
|
||||
|
|
Loading…
Reference in New Issue