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,7 +1,5 @@
"""
homeassistant.components.sensor.cpuspeed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shows the current CPU speed.
Support for displaying the current CPU speed.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.cpuspeed/
@ -15,7 +13,6 @@ REQUIREMENTS = ['py-cpuinfo==0.1.8']
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "CPU speed"
ATTR_VENDOR = 'Vendor ID'
ATTR_BRAND = 'Brand'
ATTR_HZ = 'GHz Advertised'
@ -24,14 +21,12 @@ ICON = 'mdi:pulse'
# pylint: disable=unused-variable
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the CPU speed sensor. """
"""Sets up the CPU speed sensor."""
add_devices([CpuSpeedSensor(config.get('name', DEFAULT_NAME))])
class CpuSpeedSensor(Entity):
""" A CPU info sensor. """
"""A CPU info sensor."""
def __init__(self, name):
self._name = name
self._state = None
@ -40,22 +35,22 @@ class CpuSpeedSensor(Entity):
@property
def name(self):
""" The name of the sensor. """
"""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 the value is expressed in. """
"""Unit the value is expressed in."""
return self._unit_of_measurement
@property
def device_state_attributes(self):
""" Returns the state attributes. """
"""Returns the state attributes."""
if self.info is not None:
return {
ATTR_VENDOR: self.info['vendor_id'],
@ -65,11 +60,11 @@ class CpuSpeedSensor(Entity):
@property
def icon(self):
""" Icon to use in the frontend, if any. """
"""Icon to use in the frontend, if any."""
return ICON
def update(self):
""" Gets the latest data and updates the state. """
"""Gets the latest data and updates the state."""
from cpuinfo import cpuinfo
self.info = cpuinfo.get_cpu_info()