Update docstrings (#7374)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstring

* Update docstrings

* Update docstrings

* Fix lint issues

* Update docstrings

* Revert changes in dict
This commit is contained in:
Fabian Affolter 2017-05-02 18:18:47 +02:00 committed by Paulus Schoutsen
parent 0e08925259
commit a4f1f6e724
340 changed files with 1533 additions and 1708 deletions

View file

@ -37,7 +37,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-variable
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup PwrCtrl devices/switches."""
"""Set up PwrCtrl devices/switches."""
host = config.get(CONF_HOST, None)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)

View file

@ -10,33 +10,33 @@ import asyncio
import binascii
import logging
import socket
import voluptuous as vol
import homeassistant.loader as loader
from homeassistant.util.dt import utcnow
from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.const import (CONF_FRIENDLY_NAME, CONF_SWITCHES,
CONF_COMMAND_OFF, CONF_COMMAND_ON,
CONF_TIMEOUT, CONF_HOST, CONF_MAC,
CONF_TYPE)
from homeassistant.const import (
CONF_FRIENDLY_NAME, CONF_SWITCHES, CONF_COMMAND_OFF, CONF_COMMAND_ON,
CONF_TIMEOUT, CONF_HOST, CONF_MAC, CONF_TYPE)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['broadlink==0.3']
_LOGGER = logging.getLogger(__name__)
DOMAIN = "broadlink"
DOMAIN = 'broadlink'
DEFAULT_NAME = 'Broadlink switch'
DEFAULT_TIMEOUT = 10
DEFAULT_RETRY = 3
SERVICE_LEARN = "learn_command"
SERVICE_SEND = "send_packet"
SERVICE_LEARN = 'learn_command'
SERVICE_SEND = 'send_packet'
RM_TYPES = ["rm", "rm2", "rm_mini", "rm_pro_phicomm", "rm2_home_plus",
"rm2_home_plus_gdt", "rm2_pro_plus", "rm2_pro_plus2",
"rm2_pro_plus_bl", "rm_mini_shate"]
SP1_TYPES = ["sp1"]
SP2_TYPES = ["sp2", "honeywell_sp2", "sp3", "spmini2", "spminiplus"]
RM_TYPES = ['rm', 'rm2', 'rm_mini', 'rm_pro_phicomm', 'rm2_home_plus',
'rm2_home_plus_gdt', 'rm2_pro_plus', 'rm2_pro_plus2',
'rm2_pro_plus_bl', 'rm_mini_shate']
SP1_TYPES = ['sp1']
SP2_TYPES = ['sp2', 'honeywell_sp2', 'sp3', 'spmini2', 'spminiplus']
SWITCH_TYPES = RM_TYPES + SP1_TYPES + SP2_TYPES
@ -58,7 +58,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Broadlink switches."""
"""Set up Broadlink switches."""
import broadlink
devices = config.get(CONF_SWITCHES, {})
ip_addr = config.get(CONF_HOST)
@ -75,33 +75,31 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
auth = yield from hass.loop.run_in_executor(None,
broadlink_device.auth)
except socket.timeout:
_LOGGER.error("Failed to connect to device, timeout.")
_LOGGER.error("Failed to connect to device, timeout")
return
if not auth:
_LOGGER.error("Failed to connect to device.")
_LOGGER.error("Failed to connect to device")
return
yield from hass.loop.run_in_executor(None,
broadlink_device.enter_learning)
yield from hass.loop.run_in_executor(
None, broadlink_device.enter_learning)
_LOGGER.info("Press the key you want HASS to learn")
start_time = utcnow()
while (utcnow() - start_time) < timedelta(seconds=20):
packet = yield from hass.loop.run_in_executor(None,
broadlink_device.
check_data)
packet = yield from hass.loop.run_in_executor(
None, broadlink_device.check_data)
if packet:
log_msg = 'Recieved packet is: {}'.\
log_msg = "Recieved packet is: {}".\
format(b64encode(packet).decode('utf8'))
_LOGGER.info(log_msg)
persistent_notification.async_create(hass, log_msg,
title='Broadlink switch')
persistent_notification.async_create(
hass, log_msg, title='Broadlink switch')
return
yield from asyncio.sleep(1, loop=hass.loop)
_LOGGER.error('Did not received any signal.')
persistent_notification.async_create(hass,
"Did not received any signal",
title='Broadlink switch')
_LOGGER.error("Did not received any signal")
persistent_notification.async_create(
hass, "Did not received any signal", title='Broadlink switch')
@asyncio.coroutine
def _send_packet(call):
@ -119,7 +117,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
None, broadlink_device.auth)
except socket.timeout:
if retry == DEFAULT_RETRY-1:
_LOGGER.error("Failed to send packet to device.")
_LOGGER.error("Failed to send packet to device")
if switch_type in RM_TYPES:
broadlink_device = broadlink.rm((ip_addr, 80), mac_addr)
@ -148,7 +146,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
try:
broadlink_device.auth()
except socket.timeout:
_LOGGER.error("Failed to connect to device.")
_LOGGER.error("Failed to connect to device")
add_devices(switches)
@ -199,7 +197,7 @@ class BroadlinkRMSwitch(SwitchDevice):
def _sendpacket(self, packet, retry=2):
"""Send packet to device."""
if packet is None:
_LOGGER.debug("Empty packet.")
_LOGGER.debug("Empty packet")
return True
try:
self._device.send_data(packet)

View file

@ -10,7 +10,7 @@ from homeassistant.const import DEVICE_DEFAULT_NAME
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the demo switches."""
"""Set up the demo switches."""
add_devices_callback([
DemoSwitch('Decorative Lights', True, None, True),
DemoSwitch('AC', False, 'mdi:air-conditioner', False)

View file

@ -28,7 +28,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Digital Ocean droplet switch."""
"""Set up the Digital Ocean droplet switch."""
digital_ocean = get_component('digital_ocean')
droplets = config.get(CONF_DROPLETS)

View file

@ -39,7 +39,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup a D-Link Smart Plug."""
"""Set up a D-Link Smart Plug."""
from pyW215.pyW215 import SmartPlug
host = config.get(CONF_HOST)

View file

@ -26,7 +26,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the EnOcean switch platform."""
"""Set up the EnOcean switch platform."""
dev_id = config.get(CONF_ID)
devname = config.get(CONF_NAME)

View file

@ -81,7 +81,7 @@ def set_lights_temp(hass, lights, mired, brightness):
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Flux switches."""
"""Set up the Flux switches."""
name = config.get(CONF_NAME)
lights = config.get(CONF_LIGHTS)
start_time = config.get(CONF_START_TIME)
@ -139,11 +139,11 @@ class FluxSwitch(SwitchDevice):
if self.is_on:
return
# make initial update
# Make initial update
self.flux_update()
self.unsub_tracker = track_time_change(self.hass, self.flux_update,
second=[0, 30])
self.unsub_tracker = track_time_change(
self.hass, self.flux_update, second=[0, 30])
self.schedule_update_ha_state()
@ -159,13 +159,12 @@ class FluxSwitch(SwitchDevice):
"""Update all the lights using flux."""
if now is None:
now = dt_now()
sunset = next_setting(self.hass, SUN).replace(day=now.day,
month=now.month,
year=now.year)
sunset = next_setting(self.hass, SUN).replace(
day=now.day, month=now.month, year=now.year)
start_time = self.find_start_time(now)
stop_time = now.replace(hour=self._stop_time.hour,
minute=self._stop_time.minute,
second=0)
stop_time = now.replace(
hour=self._stop_time.hour, minute=self._stop_time.minute,
second=0)
if start_time < now < sunset:
# Daytime
@ -203,26 +202,25 @@ class FluxSwitch(SwitchDevice):
if self._mode == MODE_XY:
set_lights_xy(self.hass, self._lights, x_val,
y_val, brightness)
_LOGGER.info("Lights updated to x:%s y:%s brightness:%s, %s%%"
" of %s cycle complete at %s", x_val, y_val,
_LOGGER.info("Lights updated to x:%s y:%s brightness:%s, %s%% "
"of %s cycle complete at %s", x_val, y_val,
brightness, round(
percentage_complete * 100), time_state, now)
else:
# Convert to mired and clamp to allowed values
mired = color_temperature_kelvin_to_mired(temp)
set_lights_temp(self.hass, self._lights, mired, brightness)
_LOGGER.info("Lights updated to mired:%s brightness:%s, %s%%"
" of %s cycle complete at %s", mired, brightness,
_LOGGER.info("Lights updated to mired:%s brightness:%s, %s%% "
"of %s cycle complete at %s", mired, brightness,
round(percentage_complete * 100), time_state, now)
def find_start_time(self, now):
"""Return sunrise or start_time if given."""
if self._start_time:
sunrise = now.replace(hour=self._start_time.hour,
minute=self._start_time.minute,
second=0)
sunrise = now.replace(
hour=self._start_time.hour, minute=self._start_time.minute,
second=0)
else:
sunrise = next_rising(self.hass, SUN).replace(day=now.day,
month=now.month,
year=now.year)
sunrise = next_rising(self.hass, SUN).replace(
day=now.day, month=now.month, year=now.year)
return sunrise

View file

@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Hikvision camera."""
"""Set up Hikvision camera."""
import hikvision.api
from hikvision.error import HikvisionError, MissingParamError

View file

@ -15,7 +15,7 @@ DEPENDENCIES = ['homematic']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Homematic switch platform."""
"""Set up the Homematic switch platform."""
if discovery_info is None:
return

View file

@ -25,7 +25,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the KNX switch platform."""
"""Set up the KNX switch platform."""
add_devices([KNXSwitch(hass, KNXConfig(config))])

View file

@ -1,11 +1,15 @@
"""Support for Lutron Caseta switches."""
"""
Support for Lutron Caseta switches.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sitch.lutron_caseta/
"""
import logging
from homeassistant.components.lutron_caseta import (
LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice)
from homeassistant.components.switch import SwitchDevice
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['lutron_caseta']
@ -13,7 +17,7 @@ DEPENDENCIES = ['lutron_caseta']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Lutron switch."""
"""Set up Lutron switch."""
devs = []
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
switch_devices = bridge.get_devices_by_type("WallSwitch")

View file

@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-variable
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup mFi sensors."""
"""Set up mFi sensors."""
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)

View file

@ -31,7 +31,7 @@ PLATFORM_SCHEMA = vol.Schema({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup X10 switches over a mochad controller."""
"""Set up X10 switches over a mochad controller."""
devs = config.get(CONF_DEVICES)
add_devices([MochadSwitch(
hass, mochad.CONTROLLER.ctrl, dev) for dev in devs])

View file

@ -28,7 +28,7 @@ SEND_IR_CODE_SERVICE_SCHEMA = vol.Schema({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the mysensors platform for switches."""
"""Set up the mysensors platform for switches."""
# Only act if loaded via mysensors by discovery event.
# Otherwise gateway is not setup.
if discovery_info is None:
@ -158,7 +158,7 @@ class MySensorsIRSwitch(MySensorsSwitch):
"""IR switch child class to MySensorsSwitch."""
def __init__(self, *args):
"""Setup instance attributes."""
"""Set up instance attributes."""
MySensorsSwitch.__init__(self, *args)
self._ir_code = None

View file

@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup S20 switches."""
"""Set up S20 switches."""
from orvibo.s20 import discover, S20, S20Exception
switch_data = {}

View file

@ -17,7 +17,7 @@ PLATFORM_SCHEMA = rfxtrx.DEFAULT_SCHEMA
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup the RFXtrx platform."""
"""Set up the RFXtrx platform."""
import RFXtrx as rfxtrxmod
# Add switch from config file

View file

@ -36,7 +36,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Raspberry PI GPIO devices."""
"""Set up the Raspberry PI GPIO devices."""
invert_logic = config.get(CONF_INVERT_LOGIC)
switches = []

View file

@ -31,7 +31,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the SCSGate switches."""
"""Set up the SCSGate switches."""
logger = logging.getLogger(__name__)
_setup_traditional_switches(

View file

@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Tellstick switches."""
"""Set up Tellstick switches."""
if discovery_info is None:
return
add_devices(TelldusLiveSwitch(hass, switch) for switch in discovery_info)

View file

@ -17,7 +17,7 @@ PLATFORM_SCHEMA = vol.Schema({vol.Required("platform"): DOMAIN})
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Tellstick switches."""
"""Set up Tellstick switches."""
if (discovery_info is None or
discovery_info[ATTR_DISCOVER_DEVICES] is None):
return

View file

@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@asyncio.coroutine
# pylint: disable=unused-argument
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup the Template switch."""
"""Set up the Template switch."""
switches = []
for device, device_config in config[CONF_SWITCHES].items():

View file

@ -31,7 +31,7 @@ SWITCH_TYPES = {
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ThinkingCleaner platform."""
"""Set up the ThinkingCleaner platform."""
from pythinkingcleaner import Discovery
discovery = Discovery()

View file

@ -32,7 +32,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the TPLink switch platform."""
"""Set up the TPLink switch platform."""
from pyHS100 import SmartPlug
host = config.get(CONF_HOST)
name = config.get(CONF_NAME)

View file

@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Transmission switch."""
"""Set up the Transmission switch."""
import transmissionrpc
from transmissionrpc.error import TransmissionError

View file

@ -14,7 +14,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Verisure switch platform."""
"""Set up the Verisure switch platform."""
if not int(hub.config.get(CONF_SMARTPLUGS, 1)):
return False

View file

@ -15,7 +15,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Tellstick switches."""
"""Set up Tellstick switches."""
if discovery_info is None:
return
add_devices([VolvoSwitch(hass, *discovery_info)])

View file

@ -32,7 +32,7 @@ WEMO_STANDBY = 8
# pylint: disable=unused-argument, too-many-function-args
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Setup discovered WeMo switches."""
"""Set up discovered WeMo switches."""
import pywemo.discovery as discovery
if discovery_info is not None:

View file

@ -12,7 +12,7 @@ DEPENDENCIES = ['wink']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Wink platform."""
"""Set up the Wink platform."""
import pywink
for switch in pywink.get_switches():

View file

@ -16,7 +16,7 @@ DEPENDENCIES = ['zha']
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup Zigbee Home Automation switches."""
"""Set up Zigbee Home Automation switches."""
discovery_info = zha.get_discovery_info(hass, discovery_info)
if discovery_info is None:
return

View file

@ -25,7 +25,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ZigBee switch platform."""
"""Set up the ZigBee switch platform."""
add_devices([ZigBeeSwitch(hass, ZigBeeDigitalOutConfig(config))])