1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Update/add docstrings (PEP257)

This commit is contained in:
Fabian Affolter
2016-02-23 06:21:49 +01:00
parent c64da761f1
commit 60d579af84
46 changed files with 407 additions and 510 deletions

View File

@@ -1,6 +1,4 @@
"""
homeassistant.components.sensor.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform that has a couple of fake sensors.
"""
from homeassistant.const import ATTR_BATTERY_LEVEL, TEMP_CELCIUS
@@ -9,7 +7,7 @@ from homeassistant.helpers.entity import Entity
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo sensors. """
"""Sets up the Demo sensors."""
add_devices([
DemoSensor('Outside Temperature', 15.6, TEMP_CELCIUS, 12),
DemoSensor('Outside Humidity', 54, '%', None),
@@ -17,8 +15,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoSensor(Entity):
""" A Demo sensor. """
"""A Demo sensor."""
def __init__(self, name, state, unit_of_measurement, battery):
self._name = name
self._state = state
@@ -27,27 +24,27 @@ class DemoSensor(Entity):
@property
def should_poll(self):
""" No polling needed for a demo sensor. """
"""No polling needed for a demo sensor."""
return False
@property
def name(self):
""" Returns the name of the device. """
"""Returns the name of the sensor."""
return self._name
@property
def state(self):
""" Returns the state of the device. """
"""Returns the state of the sensor."""
return self._state
@property
def unit_of_measurement(self):
""" Unit this state is expressed in. """
"""Unit this state is expressed in."""
return self._unit_of_measurement
@property
def device_state_attributes(self):
""" Returns the state attributes. """
"""Returns the state attributes."""
if self._battery:
return {
ATTR_BATTERY_LEVEL: self._battery,