From 232aa792f14db6f43d77bf581b6e441c6c34cd77 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 27 Jan 2016 07:28:18 +0100 Subject: [PATCH] Add link to docs and update docstrings --- homeassistant/components/sensor/onewire.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sensor/onewire.py b/homeassistant/components/sensor/onewire.py index 03f220544fe..1266f36485c 100644 --- a/homeassistant/components/sensor/onewire.py +++ b/homeassistant/components/sensor/onewire.py @@ -1,4 +1,11 @@ -""" Support for DS18B20 One Wire Sensors""" +""" +homeassistant.components.sensor.onewire +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Support for DS18B20 One Wire Sensors. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.onewire/ +""" from glob import glob import logging import os @@ -6,7 +13,6 @@ import time from homeassistant.const import TEMP_CELCIUS, STATE_UNKNOWN from homeassistant.helpers.entity import Entity - BASE_DIR = '/sys/bus/w1/devices/' DEVICE_FOLDERS = glob(os.path.join(BASE_DIR, '28*')) SENSOR_IDS = [] @@ -20,7 +26,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): - """ Sets up the one wire Sensors""" + """ Sets up the one wire Sensors. """ if DEVICE_FILES == []: _LOGGER.error('No onewire sensor found.') @@ -51,7 +57,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class OneWire(Entity): - """ A Dallas 1 Wire Sensor""" + """ An One wire Sensor. """ def __init__(self, name, device_file): self._name = name @@ -60,7 +66,7 @@ class OneWire(Entity): self.update() def _read_temp_raw(self): - """ read the temperature as it is returned by the sensor""" + """ Read the temperature as it is returned by the sensor. """ ds_device_file = open(self._device_file, 'r') lines = ds_device_file.readlines() ds_device_file.close() @@ -68,18 +74,21 @@ class OneWire(Entity): @property def name(self): + """ The name of the sensor. """ return self._name @property def state(self): - """ return temperature in unit_of_measurement""" + """ Returns the state of the device. """ return self._state @property def unit_of_measurement(self): + """ Unit the value is expressed in. """ return TEMP_CELCIUS def update(self): + """ Gets the latest data from the device. """ lines = self._read_temp_raw() while lines[0].strip()[-3:] != 'YES': time.sleep(0.2)