Normalise headers in onewire integration (#40774)

This commit is contained in:
epenet 2020-09-30 08:53:12 +02:00 committed by GitHub
parent 8d0f1e7db2
commit e38ae1b188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,14 +119,10 @@ def hb_info_from_type(dev_type="std"):
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the one wire Sensors."""
"""Set up 1-Wire platform."""
base_dir = config[CONF_MOUNT_DIR]
owport = config[CONF_PORT]
owhost = config.get(CONF_HOST)
if owhost:
_LOGGER.debug("Initializing using %s:%s", owhost, owport)
else:
_LOGGER.debug("Initializing using %s", base_dir)
devs = []
device_names = {}
@ -136,6 +132,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
# We have an owserver on a remote(or local) host/port
if owhost:
_LOGGER.debug("Initializing using %s:%s", owhost, owport)
try:
owproxy = protocol.proxy(host=owhost, port=owport)
devices = owproxy.dir()
@ -180,6 +177,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
# We have a raw GPIO ow sensor on a Pi
elif base_dir == DEFAULT_SYSBUS_MOUNT_DIR:
_LOGGER.debug("Initializing using SysBus %s", base_dir)
for device_family in DEVICE_SENSORS:
for device_folder in glob(os.path.join(base_dir, f"{device_family}[.-]*")):
sensor_id = os.path.split(device_folder)[1]
@ -194,6 +192,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
# We have an owfs mounted
else:
_LOGGER.debug("Initializing using OWFS %s", base_dir)
for family_file_path in glob(os.path.join(base_dir, "*", "family")):
with open(family_file_path) as family_file:
family = family_file.read()
@ -225,7 +224,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class OneWire(Entity):
"""Implementation of an One wire Sensor."""
"""Implementation of a 1-Wire sensor."""
def __init__(self, name, device_file, sensor_type):
"""Initialize the sensor."""
@ -270,10 +269,10 @@ class OneWire(Entity):
class OneWireProxy(OneWire):
"""Implementation of a One wire Sensor through owserver."""
"""Implementation of a 1-Wire sensor through owserver."""
def __init__(self, name, device_file, sensor_type, owproxy):
"""Initialize the onewire sensor via owserver."""
"""Initialize the sensor."""
super().__init__(name, device_file, sensor_type)
self._owproxy = owproxy
@ -299,7 +298,7 @@ class OneWireProxy(OneWire):
class OneWireDirect(OneWire):
"""Implementation of an One wire Sensor directly connected to RPI GPIO."""
"""Implementation of a 1-Wire sensor directly connected to RPI GPIO."""
def update(self):
"""Get the latest data from the device."""
@ -317,7 +316,7 @@ class OneWireDirect(OneWire):
class OneWireOWFS(OneWire):
"""Implementation of an One wire Sensor through owfs."""
"""Implementation of a 1-Wire sensor through owfs."""
def update(self):
"""Get the latest data from the device."""