Update/add docstrings (PEP257)
This commit is contained in:
parent
c64da761f1
commit
60d579af84
46 changed files with 407 additions and 510 deletions
|
@ -1,7 +1,5 @@
|
|||
"""
|
||||
homeassistant.components.sensor.sabnzbd
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Monitors SABnzbd NZB client API.
|
||||
Support for monitoring an SABnzbd NZB client.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.sabnzbd/
|
||||
|
@ -26,13 +24,12 @@ SENSOR_TYPES = {
|
|||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_THROTTLED_REFRESH = None
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the SABnzbd sensors. """
|
||||
"""Sets up the SABnzbd sensors."""
|
||||
from pysabnzbd import SabnzbdApi, SabnzbdApiException
|
||||
|
||||
api_key = config.get("api_key")
|
||||
|
@ -68,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
|
||||
class SabnzbdSensor(Entity):
|
||||
""" Represents an SABnzbd sensor. """
|
||||
"""Represents an SABnzbd sensor."""
|
||||
|
||||
def __init__(self, sensor_type, sabnzb_client, client_name):
|
||||
self._name = SENSOR_TYPES[sensor_type][0]
|
||||
|
@ -80,20 +77,21 @@ class SabnzbdSensor(Entity):
|
|||
|
||||
@property
|
||||
def name(self):
|
||||
"""Returns the name of the sensor."""
|
||||
return self.client_name + ' ' + 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 of measurement of this entity, if any. """
|
||||
"""Unit of measurement of this entity, if any."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
def refresh_sabnzbd_data(self):
|
||||
""" Calls the throttled SABnzbd refresh method. """
|
||||
"""Calls the throttled SABnzbd refresh method."""
|
||||
if _THROTTLED_REFRESH is not None:
|
||||
from pysabnzbd import SabnzbdApiException
|
||||
try:
|
||||
|
@ -104,6 +102,7 @@ class SabnzbdSensor(Entity):
|
|||
)
|
||||
|
||||
def update(self):
|
||||
"""Gets the latest data and updates the states."""
|
||||
self.refresh_sabnzbd_data()
|
||||
if self.sabnzb_client.queue:
|
||||
if self.type == 'current_status':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue