Add docstrings, fix typos, and update docsstring for PEP257

This commit is contained in:
Fabian Affolter 2016-02-22 10:11:46 +01:00
parent 7a0c99a1d5
commit fd3ea95b82
15 changed files with 67 additions and 89 deletions

View file

@ -1,6 +1,4 @@
"""
homeassistant.components.binary_sensor.arest
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The arest sensor will consume an exposed aREST API of a device.
For more details about this platform, please refer to the documentation at
@ -24,8 +22,7 @@ CONF_PIN = 'pin'
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the aREST binary sensor. """
"""Get the aREST binary sensor."""
resource = config.get(CONF_RESOURCE)
pin = config.get(CONF_PIN)
@ -56,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-instance-attributes, too-many-arguments
class ArestBinarySensor(BinarySensorDevice):
""" Implements an aREST binary sensor for a pin. """
"""Implements an aREST binary sensor for a pin."""
def __init__(self, arest, resource, name, pin):
self.arest = arest
@ -73,23 +70,22 @@ class ArestBinarySensor(BinarySensorDevice):
@property
def name(self):
""" The name of the binary sensor. """
"""The name of the binary sensor."""
return self._name
@property
def is_on(self):
""" True if the binary sensor is on. """
"""True if the binary sensor is on."""
return bool(self.arest.data.get('state'))
def update(self):
""" Gets the latest data from aREST API. """
"""Gets the latest data from aREST API."""
self.arest.update()
# pylint: disable=too-few-public-methods
class ArestData(object):
""" Class for handling the data retrieval for pins. """
"""Class for handling the data retrieval for pins."""
def __init__(self, resource, pin):
self._resource = resource
self._pin = pin
@ -97,7 +93,7 @@ class ArestData(object):
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from aREST device. """
"""Gets the latest data from aREST device."""
try:
response = requests.get('{}/digital/{}'.format(
self._resource, self._pin), timeout=10)