Update docstrings (#7361)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update tomato.py

* Update isy994.py

* Lint + fix tests

* Lint
This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2017-04-29 22:04:49 -07:00
1 parent e22e70a01a
commit 3ee4d1060f
264 files changed
+1686 -1768

No files matched your search

+1 -2
View File
@@ -24,6 +24,7 @@ from homeassistant.const import (
SERVICE_STOP_COVER_TILT, SERVICE_SET_COVER_TILT_POSITION, STATE_OPEN,
STATE_CLOSED, STATE_UNKNOWN, ATTR_ENTITY_ID)
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'cover'
SCAN_INTERVAL = timedelta(seconds=15)
@@ -47,8 +48,6 @@ SUPPORT_CLOSE_TILT = 32
SUPPORT_STOP_TILT = 64
SUPPORT_SET_TILT_POSITION = 128
_LOGGER = logging.getLogger(__name__)
ATTR_CURRENT_POSITION = 'current_position'
ATTR_CURRENT_TILT_POSITION = 'current_tilt_position'
ATTR_POSITION = 'position'
@@ -32,7 +32,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup cover controlled by shell commands."""
"""Set up cover controlled by shell commands."""
devices = config.get(CONF_COVERS, {})
covers = []
@@ -78,25 +78,25 @@ class CommandCover(CoverDevice):
@staticmethod
def _move_cover(command):
"""Execute the actual commands."""
_LOGGER.info('Running command: %s', command)
_LOGGER.info("Running command: %s", command)
success = (subprocess.call(command, shell=True) == 0)
if not success:
_LOGGER.error('Command failed: %s', command)
_LOGGER.error("Command failed: %s", command)
return success
@staticmethod
def _query_state_value(command):
"""Execute state command for return value."""
_LOGGER.info('Running state command: %s', command)
_LOGGER.info("Running state command: %s", command)
try:
return_value = subprocess.check_output(command, shell=True)
return return_value.strip().decode('utf-8')
except subprocess.CalledProcessError:
_LOGGER.error('Command failed: %s', command)
_LOGGER.error("Command failed: %s", command)
@property
def should_poll(self):
@@ -128,7 +128,7 @@ class CommandCover(CoverDevice):
def _query_state(self):
"""Query for the state."""
if not self._command_state:
_LOGGER.error('No state command specified')
_LOGGER.error("No state command specified")
return
return self._query_state_value(self._command_state)
+1 -1
View File
@@ -10,7 +10,7 @@ from homeassistant.helpers.event import track_utc_time_change
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Demo covers."""
"""Set up the Demo covers."""
add_devices([
DemoCover(hass, 'Kitchen Window'),
DemoCover(hass, 'Hall Window', 10),
+2 -6
View File
@@ -3,11 +3,7 @@ The homematic cover platform.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/cover.homematic/
Important: For this platform to work the homematic component has to be
properly configured.
"""
import logging
from homeassistant.const import STATE_UNKNOWN
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
@@ -19,7 +15,7 @@ DEPENDENCIES = ['homematic']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the platform."""
"""Set up the platform."""
if discovery_info is None:
return
@@ -33,7 +29,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class HMCover(HMDevice, CoverDevice):
"""Represents a Homematic Cover in Home Assistant."""
"""Representation a Homematic Cover."""
@property
def current_cover_position(self):
+8 -10
View File
@@ -12,7 +12,6 @@ import homeassistant.components.isy994 as isy
from homeassistant.const import STATE_OPEN, STATE_CLOSED, STATE_UNKNOWN
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
VALUE_TO_STATE = {
@@ -27,15 +26,14 @@ STATES = [STATE_OPEN, STATE_CLOSED, 'closing', 'opening', 'stopped']
# pylint: disable=unused-argument
def setup_platform(hass, config: ConfigType,
add_devices: Callable[[list], None], discovery_info=None):
"""Setup the ISY994 cover platform."""
"""Set up the ISY994 cover platform."""
if isy.ISY is None or not isy.ISY.connected:
_LOGGER.error('A connection has not been made to the ISY controller.')
_LOGGER.error("A connection has not been made to the ISY controller")
return False
devices = []
for node in isy.filter_nodes(isy.NODES, units=UOM,
states=STATES):
for node in isy.filter_nodes(isy.NODES, units=UOM, states=STATES):
devices.append(ISYCoverDevice(node))
for program in isy.PROGRAMS.get(DOMAIN, []):
@@ -60,7 +58,7 @@ class ISYCoverDevice(isy.ISYDevice, CoverDevice):
@property
def current_cover_position(self) -> int:
"""Get the current cover position."""
"""Return the current cover position."""
return sorted((0, self.value, 100))[1]
@property
@@ -76,12 +74,12 @@ class ISYCoverDevice(isy.ISYDevice, CoverDevice):
def open_cover(self, **kwargs) -> None:
"""Send the open cover command to the ISY994 cover device."""
if not self._node.on(val=100):
_LOGGER.error('Unable to open the cover')
_LOGGER.error("Unable to open the cover")
def close_cover(self, **kwargs) -> None:
"""Send the close cover command to the ISY994 cover device."""
if not self._node.off():
_LOGGER.error('Unable to close the cover')
_LOGGER.error("Unable to close the cover")
class ISYCoverProgram(ISYCoverDevice):
@@ -101,9 +99,9 @@ class ISYCoverProgram(ISYCoverDevice):
def open_cover(self, **kwargs) -> None:
"""Send the open cover command to the ISY994 cover program."""
if not self._actions.runThen():
_LOGGER.error('Unable to open the cover')
_LOGGER.error("Unable to open the cover")
def close_cover(self, **kwargs) -> None:
"""Send the close cover command to the ISY994 cover program."""
if not self._actions.runElse():
_LOGGER.error('Unable to close the cover')
_LOGGER.error("Unable to close the cover")
+3 -3
View File
@@ -49,7 +49,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup the MQTT Cover."""
"""Set up the MQTT Cover."""
value_template = config.get(CONF_VALUE_TEMPLATE)
if value_template is not None:
value_template.hass = hass
@@ -94,13 +94,13 @@ class MqttCover(CoverDevice):
@asyncio.coroutine
def async_added_to_hass(self):
"""Subscribe mqtt events.
"""Subscribe MQTT events.
This method is a coroutine.
"""
@callback
def message_received(topic, payload, qos):
"""A new MQTT message has been received."""
"""Handle new MQTT message."""
if self._template is not None:
payload = self._template.async_render_with_possible_json_value(
payload)
+5 -5
View File
@@ -27,7 +27,7 @@ DEFAULT_NAME = 'myq'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the MyQ component."""
"""Set up the MyQ component."""
from pymyq import MyQAPI as pymyq
username = config.get(CONF_USERNAME)
@@ -39,17 +39,17 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
myq = pymyq(username, password, brand)
if not myq.is_supported_brand():
logger.error('MyQ Cover - Unsupported Type. See documentation')
logger.error("Unsupported type. See documentation")
return
if not myq.is_login_valid():
logger.error('MyQ Cover - Username or Password is incorrect')
logger.error("Username or Password is incorrect")
return
try:
add_devices(MyQDevice(myq, door) for door in myq.get_garage_doors())
except (TypeError, KeyError, NameError) as ex:
logger.error("MyQ Cover - %s", ex)
logger.error("%s", ex)
class MyQDevice(CoverDevice):
@@ -74,7 +74,7 @@ class MyQDevice(CoverDevice):
@property
def is_closed(self):
"""Return True if cover is closed, else False."""
"""Return true if cover is closed, else False."""
return self._status == STATE_CLOSED
def close_cover(self):
+2 -1
View File
@@ -11,11 +11,12 @@ from homeassistant.components.cover import CoverDevice, ATTR_POSITION
from homeassistant.const import STATE_ON, STATE_OFF
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = []
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the mysensors platform for covers."""
"""Set up the MySensors platform for covers."""
if discovery_info is None:
return
+6 -9
View File
@@ -4,7 +4,6 @@ Support for RFXtrx cover components.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/cover.rfxtrx/
"""
import homeassistant.components.rfxtrx as rfxtrx
from homeassistant.components.cover import CoverDevice
@@ -14,16 +13,14 @@ PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the RFXtrx cover."""
"""Set up the RFXtrx cover."""
import RFXtrx as rfxtrxmod
# Add cover from config file
covers = rfxtrx.get_devices_from_config(config,
RfxtrxCover)
covers = rfxtrx.get_devices_from_config(config, RfxtrxCover)
add_devices_callback(covers)
def cover_update(event):
"""Callback for cover updates from the RFXtrx gateway."""
"""Handle cover updates from the RFXtrx gateway."""
if not isinstance(event.device, rfxtrxmod.LightingDevice) or \
event.device.known_to_be_dimmable or \
not event.device.known_to_be_rollershutter:
@@ -35,17 +32,17 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
rfxtrx.apply_received_command(event)
# Subscribe to main rfxtrx events
# Subscribe to main RFXtrx events
if cover_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(cover_update)
class RfxtrxCover(rfxtrx.RfxtrxDevice, CoverDevice):
"""Representation of an rfxtrx cover."""
"""Representation of a RFXtrx cover."""
@property
def should_poll(self):
"""No polling available in rfxtrx cover."""
"""No polling available in RFXtrx cover."""
return False
@property
+2 -2
View File
@@ -1,5 +1,5 @@
"""
Support for building a Raspberry Pi cover in HA.
Support for controlling a Raspberry Pi cover.
Instructions for building the controller can be found here
https://github.com/andrewshilliday/garage-door-controller
@@ -50,7 +50,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the RPi cover platform."""
"""Set up the RPi cover platform."""
relay_time = config.get(CONF_RELAY_TIME)
state_pull_mode = config.get(CONF_STATE_PULL_MODE)
covers = []
+1 -1
View File
@@ -23,7 +23,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the SCSGate cover."""
"""Set up the SCSGate cover."""
devices = config.get(CONF_DEVICES)
covers = []
logger = logging.getLogger(__name__)
@@ -5,7 +5,6 @@ This platform uses the Telldus Live online service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/cover.tellduslive/
"""
import logging
@@ -16,9 +15,10 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup covers."""
"""Set up the Telldus Live covers."""
if discovery_info is None:
return
add_devices(TelldusLiveCover(hass, cover) for cover in discovery_info)
+2 -2
View File
@@ -16,14 +16,14 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Find and return Vera covers."""
"""Set up the Vera covers."""
add_devices(
VeraCover(device, VERA_CONTROLLER) for
device in VERA_DEVICES['cover'])
class VeraCover(VeraDevice, CoverDevice):
"""Represents a Vera Cover in Home Assistant."""
"""Representation a Vera Cover."""
def __init__(self, vera_device, controller):
"""Initialize the Vera device."""
+1 -2
View File
@@ -4,7 +4,6 @@ Support for Wink Covers.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/cover.wink/
"""
from homeassistant.components.cover import CoverDevice
from homeassistant.components.wink import WinkDevice, DOMAIN
@@ -12,7 +11,7 @@ DEPENDENCIES = ['wink']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Wink cover platform."""
"""Set up the Wink cover platform."""
import pywink
for shade in pywink.get_shades():
+5 -5
View File
@@ -1,5 +1,5 @@
"""
Support for Zwave cover components.
Support for Z-Wave cover components.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/cover.zwave/
@@ -21,7 +21,7 @@ SUPPORT_GARAGE = SUPPORT_OPEN | SUPPORT_CLOSE
def get_device(hass, values, node_config, **kwargs):
"""Create zwave entity device."""
"""Create Z-Wave entity device."""
invert_buttons = node_config.get(zwave.CONF_INVERT_OPENCLOSE_BUTTONS)
if (values.primary.command_class ==
zwave.const.COMMAND_CLASS_SWITCH_MULTILEVEL
@@ -35,10 +35,10 @@ def get_device(hass, values, node_config, **kwargs):
class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
"""Representation of an Zwave roller shutter."""
"""Representation of an Z-Wave cover."""
def __init__(self, hass, values, invert_buttons):
"""Initialize the zwave rollershutter."""
"""Initialize the Z-Wave rollershutter."""
ZWaveDeviceEntity.__init__(self, values, DOMAIN)
# pylint: disable=no-member
self._network = hass.data[zwave.ZWAVE_NETWORK]
@@ -53,7 +53,7 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
self.update_properties()
def update_properties(self):
"""Callback on data changes for node values."""
"""Handle data changes for node values."""
# Position value
self._current_position = self.values.primary.data