From 5d5547cdb6dd91924e719c0b5e61e2b89e48e14b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 26 Mar 2017 15:50:40 +0200 Subject: [PATCH] Update docstrings (#6795) * Add link to docs and remove comments which are obvious * Update docstrings * Repleace conf details with link to docs * Add link to docs * Update docstrings * Update import * Update ordering * Update ordering * Update docstring * Update ordering * Update ordering --- .../components/binary_sensor/blink.py | 2 +- .../components/binary_sensor/workday.py | 32 ++--- homeassistant/components/blink.py | 26 ++-- homeassistant/components/climate/tado.py | 118 +++++++++--------- homeassistant/components/light/piglow.py | 10 +- .../components/light/yeelightsunflower.py | 16 ++- .../media_player/frontier_silicon.py | 6 +- .../components/media_player/volumio.py | 55 +++----- homeassistant/components/notify/ciscospark.py | 6 +- .../components/sensor/api_streams.py | 10 +- homeassistant/components/sensor/blink.py | 7 +- homeassistant/components/sensor/ring.py | 4 +- homeassistant/components/tado.py | 46 ++++--- homeassistant/components/twilio.py | 14 ++- 14 files changed, 160 insertions(+), 192 deletions(-) diff --git a/homeassistant/components/binary_sensor/blink.py b/homeassistant/components/binary_sensor/blink.py index 8d84ffb9c90..1e95d4d466b 100644 --- a/homeassistant/components/binary_sensor/blink.py +++ b/homeassistant/components/binary_sensor/blink.py @@ -11,7 +11,7 @@ DEPENDENCIES = ['blink'] def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the blink binary sensors.""" + """Set up the blink binary sensors.""" if discovery_info is None: return diff --git a/homeassistant/components/binary_sensor/workday.py b/homeassistant/components/binary_sensor/workday.py index 1b53738a25f..c2590925df7 100644 --- a/homeassistant/components/binary_sensor/workday.py +++ b/homeassistant/components/binary_sensor/workday.py @@ -1,4 +1,9 @@ -"""Sensor to indicate whether the current day is a workday.""" +""" +Sensor to indicate whether the current day is a workday. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/binary_sensor.workday/ +""" import asyncio import logging import datetime @@ -6,8 +11,8 @@ import datetime import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import (STATE_ON, STATE_OFF, STATE_UNKNOWN, - CONF_NAME, WEEKDAYS) +from homeassistant.const import ( + STATE_ON, STATE_OFF, STATE_UNKNOWN, CONF_NAME, WEEKDAYS) import homeassistant.util.dt as dt_util from homeassistant.helpers.entity import Entity import homeassistant.helpers.config_validation as cv @@ -48,29 +53,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the Workday sensor.""" + """Set up the Workday sensor.""" import holidays - # Get the Sensor name from the config sensor_name = config.get(CONF_NAME) - - # Get the country code from the config country = config.get(CONF_COUNTRY) - - # Get the province from the config province = config.get(CONF_PROVINCE) - - # Get the list of workdays from the config workdays = config.get(CONF_WORKDAYS) - - # Get the list of excludes from the config excludes = config.get(CONF_EXCLUDES) - # Instantiate the holidays module for the current year year = datetime.datetime.now().year obj_holidays = getattr(holidays, country)(years=year) - # Also apply the provience, if available for the configured country if province: if province not in obj_holidays.PROVINCES: _LOGGER.error('There is no province/state %s in country %s', @@ -81,14 +75,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): obj_holidays = getattr(holidays, country)(prov=province, years=year) - # Output found public holidays via the debug channel _LOGGER.debug("Found the following holidays for your configuration:") for date, name in sorted(obj_holidays.items()): _LOGGER.debug("%s %s", date, name) - # Add ourselves as device - add_devices([IsWorkdaySensor(obj_holidays, workdays, - excludes, sensor_name)], True) + add_devices([IsWorkdaySensor( + obj_holidays, workdays, excludes, sensor_name)], True) def day_to_string(day): @@ -122,7 +114,6 @@ class IsWorkdaySensor(Entity): def is_include(self, day, now): """Check if given day is in the includes list.""" - # Check includes if day in self._workdays: return True elif 'holiday' in self._workdays and now in self._obj_holidays: @@ -132,7 +123,6 @@ class IsWorkdaySensor(Entity): def is_exclude(self, day, now): """Check if given day is in the excludes list.""" - # Check excludes if day in self._excludes: return True elif 'holiday' in self._excludes and now in self._obj_holidays: diff --git a/homeassistant/components/blink.py b/homeassistant/components/blink.py index 2a079716b68..4ae5007d665 100644 --- a/homeassistant/components/blink.py +++ b/homeassistant/components/blink.py @@ -5,17 +5,19 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/blink/ """ import logging + import voluptuous as vol + import homeassistant.helpers.config_validation as cv -from homeassistant.const import (CONF_USERNAME, - CONF_PASSWORD, - ATTR_FRIENDLY_NAME, - ATTR_ARMED) +from homeassistant.const import ( + CONF_USERNAME, CONF_PASSWORD, ATTR_FRIENDLY_NAME, ATTR_ARMED) from homeassistant.helpers import discovery + +REQUIREMENTS = ['blinkpy==0.5.2'] + _LOGGER = logging.getLogger(__name__) DOMAIN = 'blink' -REQUIREMENTS = ['blinkpy==0.5.2'] CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ @@ -50,7 +52,7 @@ class BlinkSystem(object): def setup(hass, config): - """Setup Blink System.""" + """Set up Blink System.""" hass.data[DOMAIN] = BlinkSystem(config) discovery.load_platform(hass, 'camera', DOMAIN, {}, config) discovery.load_platform(hass, 'sensor', DOMAIN, {}, config) @@ -77,11 +79,11 @@ def setup(hass, config): hass.data[DOMAIN].blink.arm = value hass.data[DOMAIN].blink.refresh() - hass.services.register(DOMAIN, 'snap_picture', snap_picture, - schema=SNAP_PICTURE_SCHEMA) - hass.services.register(DOMAIN, 'arm_camera', arm_camera, - schema=ARM_CAMERA_SCHEMA) - hass.services.register(DOMAIN, 'arm_system', arm_system, - schema=ARM_SYSTEM_SCHEMA) + hass.services.register( + DOMAIN, 'snap_picture', snap_picture, schema=SNAP_PICTURE_SCHEMA) + hass.services.register( + DOMAIN, 'arm_camera', arm_camera, schema=ARM_CAMERA_SCHEMA) + hass.services.register( + DOMAIN, 'arm_system', arm_system, schema=ARM_SYSTEM_SCHEMA) return True diff --git a/homeassistant/components/climate/tado.py b/homeassistant/components/climate/tado.py index e5242f88162..734b13dc7e7 100644 --- a/homeassistant/components/climate/tado.py +++ b/homeassistant/components/climate/tado.py @@ -1,40 +1,40 @@ -"""tado component to create a climate device for each zone.""" +""" +Tado component to create a climate device for each zone. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/climate.tado/ +""" import logging from homeassistant.const import TEMP_CELSIUS - -from homeassistant.components.climate import ( - ClimateDevice) -from homeassistant.const import ( - ATTR_TEMPERATURE) -from homeassistant.components.tado import ( - DATA_TADO) - -CONST_MODE_SMART_SCHEDULE = "SMART_SCHEDULE" # Default mytado mode -CONST_MODE_OFF = "OFF" # Switch off heating in a zone - -# When we change the temperature setting, we need an overlay mode -# wait until tado changes the mode automatic -CONST_OVERLAY_TADO_MODE = "TADO_MODE" -# the user has change the temperature or mode manually -CONST_OVERLAY_MANUAL = "MANUAL" -# the temperature will be reset after a timespan -CONST_OVERLAY_TIMER = "TIMER" - -OPERATION_LIST = { - CONST_OVERLAY_MANUAL: "Manual", - CONST_OVERLAY_TIMER: "Timer", - CONST_OVERLAY_TADO_MODE: "Tado mode", - CONST_MODE_SMART_SCHEDULE: "Smart schedule", - CONST_MODE_OFF: "Off"} +from homeassistant.components.climate import ClimateDevice +from homeassistant.const import ATTR_TEMPERATURE +from homeassistant.components.tado import DATA_TADO _LOGGER = logging.getLogger(__name__) +CONST_MODE_SMART_SCHEDULE = 'SMART_SCHEDULE' # Default mytado mode +CONST_MODE_OFF = 'OFF' # Switch off heating in a zone + +# When we change the temperature setting, we need an overlay mode +# wait until tado changes the mode automatic +CONST_OVERLAY_TADO_MODE = 'TADO_MODE' +# the user has change the temperature or mode manually +CONST_OVERLAY_MANUAL = 'MANUAL' +# the temperature will be reset after a timespan +CONST_OVERLAY_TIMER = 'TIMER' + +OPERATION_LIST = { + CONST_OVERLAY_MANUAL: 'Manual', + CONST_OVERLAY_TIMER: 'Timer', + CONST_OVERLAY_TADO_MODE: 'Tado mode', + CONST_MODE_SMART_SCHEDULE: 'Smart schedule', + CONST_MODE_OFF: 'Off', +} + def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the climate platform.""" - # get the PyTado object from the hub component + """Set up the Tado climate platform.""" tado = hass.data[DATA_TADO] try: @@ -45,10 +45,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): climate_devices = [] for zone in zones: - climate_devices.append(create_climate_device(tado, hass, - zone, - zone['name'], - zone['id'])) + climate_devices.append(create_climate_device( + tado, hass, zone, zone['name'], zone['id'])) if len(climate_devices) > 0: add_devices(climate_devices, True) @@ -58,13 +56,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None): def create_climate_device(tado, hass, zone, name, zone_id): - """Create a climate device.""" + """Create a Tado climate device.""" capabilities = tado.get_capabilities(zone_id) unit = TEMP_CELSIUS - min_temp = float(capabilities["temperatures"]["celsius"]["min"]) - max_temp = float(capabilities["temperatures"]["celsius"]["max"]) - ac_mode = capabilities["type"] != "HEATING" + min_temp = float(capabilities['temperatures']['celsius']['min']) + max_temp = float(capabilities['temperatures']['celsius']['max']) + ac_mode = capabilities['type'] != 'HEATING' data_id = 'zone {} {}'.format(name, zone_id) device = TadoClimate(tado, @@ -74,10 +72,10 @@ def create_climate_device(tado, hass, zone, name, zone_id): ac_mode) tado.add_sensor(data_id, { - "id": zone_id, - "zone": zone, - "name": name, - "climate": device + 'id': zone_id, + 'zone': zone, + 'name': name, + 'climate': device }) return device @@ -89,7 +87,7 @@ class TadoClimate(ClimateDevice): def __init__(self, store, zone_name, zone_id, data_id, min_temp, max_temp, ac_mode, tolerance=0.3): - """Initialization of TadoClimate device.""" + """Initialization of Tado climate device.""" self._store = store self._data_id = data_id @@ -202,8 +200,7 @@ class TadoClimate(ClimateDevice): data = self._store.get_data(self._data_id) if data is None: - _LOGGER.debug('Recieved no data for zone %s', - self.zone_name) + _LOGGER.debug("Recieved no data for zone %s", self.zone_name) return if 'sensorDataPoints' in data: @@ -232,11 +229,11 @@ class TadoClimate(ClimateDevice): if 'tadoMode' in data: mode = data['tadoMode'] - self._is_away = mode == "AWAY" + self._is_away = mode == 'AWAY' if 'setting' in data: power = data['setting']['power'] - if power == "OFF": + if power == 'OFF': self._current_operation = CONST_MODE_OFF self._device_is_active = False else: @@ -249,48 +246,47 @@ class TadoClimate(ClimateDevice): overlay = False termination = "" - # if you set mode manualy to off, there will be an overlay - # and a termination, but we want to see the mode "OFF" + # If you set mode manualy to off, there will be an overlay + # and a termination, but we want to see the mode "OFF" if overlay and self._device_is_active: - # there is an overlay the device is on + # There is an overlay the device is on self._overlay_mode = termination self._current_operation = termination else: - # there is no overlay, the mode will always be - # "SMART_SCHEDULE" + # There is no overlay, the mode will always be + # "SMART_SCHEDULE" self._overlay_mode = CONST_MODE_SMART_SCHEDULE self._current_operation = CONST_MODE_SMART_SCHEDULE def _control_heating(self): """Send new target temperature to mytado.""" - if not self._active and None not in (self._cur_temp, - self._target_temp): + if not self._active and None not in ( + self._cur_temp, self._target_temp): self._active = True - _LOGGER.info('Obtained current and target temperature. ' - 'tado thermostat active.') + _LOGGER.info("Obtained current and target temperature. " + "Tado thermostat active") if not self._active or self._current_operation == self._overlay_mode: return if self._current_operation == CONST_MODE_SMART_SCHEDULE: - _LOGGER.info('Switching mytado.com to SCHEDULE (default) ' - 'for zone %s', self.zone_name) + _LOGGER.info("Switching mytado.com to SCHEDULE (default) " + "for zone %s", self.zone_name) self._store.reset_zone_overlay(self.zone_id) self._overlay_mode = self._current_operation return if self._current_operation == CONST_MODE_OFF: - _LOGGER.info('Switching mytado.com to OFF for zone %s', + _LOGGER.info("Switching mytado.com to OFF for zone %s", self.zone_name) self._store.set_zone_overlay(self.zone_id, CONST_OVERLAY_MANUAL) self._overlay_mode = self._current_operation return - _LOGGER.info('Switching mytado.com to %s mode for zone %s', + _LOGGER.info("Switching mytado.com to %s mode for zone %s", self._current_operation, self.zone_name) - self._store.set_zone_overlay(self.zone_id, - self._current_operation, - self._target_temp) + self._store.set_zone_overlay( + self.zone_id, self._current_operation, self._target_temp) self._overlay_mode = self._current_operation diff --git a/homeassistant/components/light/piglow.py b/homeassistant/components/light/piglow.py index d4e9c9ed106..afdda745721 100644 --- a/homeassistant/components/light/piglow.py +++ b/homeassistant/components/light/piglow.py @@ -9,15 +9,12 @@ import subprocess import voluptuous as vol -# Import the device class from the component that you want to support +import homeassistant.helpers.config_validation as cv from homeassistant.components.light import ( - ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, - ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, + ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, Light, PLATFORM_SCHEMA) from homeassistant.const import CONF_NAME -import homeassistant.helpers.config_validation as cv -# Home Assistant depends on 3rd party packages for API specific code. REQUIREMENTS = ['piglow==1.2.4'] _LOGGER = logging.getLogger(__name__) @@ -32,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the Piglow Light platform.""" + """Set up the Piglow Light platform.""" import piglow if subprocess.getoutput("i2cdetect -q -y 1 | grep -o 54") != '54': @@ -41,7 +38,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): name = config.get(CONF_NAME) - # Add devices add_devices([PiglowLight(piglow, name)]) diff --git a/homeassistant/components/light/yeelightsunflower.py b/homeassistant/components/light/yeelightsunflower.py index 204803e9991..70df2136716 100644 --- a/homeassistant/components/light/yeelightsunflower.py +++ b/homeassistant/components/light/yeelightsunflower.py @@ -5,21 +5,19 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.yeelightsunflower/ """ import logging + import voluptuous as vol -from homeassistant.components.light import (Light, - ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, - ATTR_BRIGHTNESS, - SUPPORT_BRIGHTNESS, - PLATFORM_SCHEMA) -from homeassistant.const import CONF_HOST import homeassistant.helpers.config_validation as cv +from homeassistant.components.light import ( + Light, ATTR_RGB_COLOR, SUPPORT_RGB_COLOR, ATTR_BRIGHTNESS, + SUPPORT_BRIGHTNESS, PLATFORM_SCHEMA) +from homeassistant.const import CONF_HOST REQUIREMENTS = ['yeelightsunflower==0.0.8'] _LOGGER = logging.getLogger(__name__) - SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -35,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): hub = yeelightsunflower.Hub(host) if not hub.available: - _LOGGER.error('Could not connect to Yeelight Sunflower hub') + _LOGGER.error("Could not connect to Yeelight Sunflower hub") return False add_devices(SunflowerBulb(light) for light in hub.get_lights()) @@ -55,7 +53,7 @@ class SunflowerBulb(Light): @property def name(self): """Return the display name of this light.""" - return "sunflower_{}".format(self._light.zid) + return 'sunflower_{}'.format(self._light.zid) @property def available(self): diff --git a/homeassistant/components/media_player/frontier_silicon.py b/homeassistant/components/media_player/frontier_silicon.py index 386a489b646..8bd36b4535c 100644 --- a/homeassistant/components/media_player/frontier_silicon.py +++ b/homeassistant/components/media_player/frontier_silicon.py @@ -42,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup the Frontier Silicon platform.""" + """Set up the Frontier Silicon platform.""" import requests if discovery_info is not None: @@ -59,10 +59,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices( [FSAPIDevice(DEVICE_URL.format(host, port), password)], update_before_add=True) - _LOGGER.debug('FSAPI device %s:%s -> %s', host, port, password) + _LOGGER.debug("FSAPI device %s:%s -> %s", host, port, password) return True except requests.exceptions.RequestException: - _LOGGER.error('Could not add the FSAPI device at %s:%s -> %s', + _LOGGER.error("Could not add the FSAPI device at %s:%s -> %s", host, port, password) return False diff --git a/homeassistant/components/media_player/volumio.py b/homeassistant/components/media_player/volumio.py index 46345f9c7f3..bcd4ebd0c11 100755 --- a/homeassistant/components/media_player/volumio.py +++ b/homeassistant/components/media_player/volumio.py @@ -1,49 +1,31 @@ """ Volumio Platform. -The volumio platform allows you to control a Volumio media player -from Home Assistant. - - -To add a Volumio player to your installation, add the following to -your configuration.yaml file. - -# Example configuration.yaml entry -media_player: - - platform: volumio - name: 'Volumio Home Audio' - host: homeaudio.local - port: 3000 -Configuration variables: - -- **name** (*Optional*): Name of the device -- **host** (*Required*): IP address or hostname of the device -- **port** (*Required*): Port number of Volumio service +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.volumio/ """ import logging import asyncio import aiohttp + import voluptuous as vol from homeassistant.components.media_player import ( - SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, - SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK, - SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, - SUPPORT_VOLUME_SET, SUPPORT_STOP, - SUPPORT_PLAY, MediaPlayerDevice, - PLATFORM_SCHEMA, MEDIA_TYPE_MUSIC) + SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK, + SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_STOP, + SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA, MEDIA_TYPE_MUSIC) from homeassistant.const import ( STATE_PLAYING, STATE_PAUSED, STATE_IDLE, CONF_HOST, CONF_PORT, CONF_NAME) import homeassistant.helpers.config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession - _CONFIGURING = {} _LOGGER = logging.getLogger(__name__) DEFAULT_HOST = 'localhost' DEFAULT_NAME = 'Volumio' DEFAULT_PORT = 3000 + TIMEOUT = 10 SUPPORT_VOLUMIO = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ @@ -60,10 +42,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): - """Setup the Volumio platform.""" + """Set up the Volumio platform.""" host = config.get(CONF_HOST) port = config.get(CONF_PORT) name = config.get(CONF_NAME) + async_add_devices([Volumio(name, host, port, hass)]) @@ -75,7 +58,7 @@ class Volumio(MediaPlayerDevice): self.host = host self.port = port self.hass = hass - self._url = host + ":" + str(port) + self._url = '{}:{}'.format(host, str(port)) self._name = name self._state = {} self.async_update() @@ -84,8 +67,7 @@ class Volumio(MediaPlayerDevice): @asyncio.coroutine def send_volumio_msg(self, method, params=None): """Send message.""" - url = "http://{}:{}/api/v1/{}/".format( - self.host, self.port, method) + url = "http://{}:{}/api/v1/{}/".format(self.host, self.port, method) response = None _LOGGER.debug("URL: %s params: %s", url, params) @@ -218,9 +200,8 @@ class Volumio(MediaPlayerDevice): def async_set_volume_level(self, volume): """Send volume_up command to media player.""" - return self.send_volumio_msg('commands', - params={'cmd': 'volume', - 'volume': int(volume * 100)}) + return self.send_volumio_msg( + 'commands', params={'cmd': 'volume', 'volume': int(volume * 100)}) def async_mute_volume(self, mute): """Send mute command to media player.""" @@ -228,10 +209,8 @@ class Volumio(MediaPlayerDevice): if mute: # mute is implemenhted as 0 volume, do save last volume level self._lastvol = self._state['volume'] - return self.send_volumio_msg('commands', - params={'cmd': 'volume', - 'volume': mutecmd}) + return self.send_volumio_msg( + 'commands', params={'cmd': 'volume', 'volume': mutecmd}) else: - return self.send_volumio_msg('commands', - params={'cmd': 'volume', - 'volume': self._lastvol}) + return self.send_volumio_msg( + 'commands', params={'cmd': 'volume', 'volume': self._lastvol}) diff --git a/homeassistant/components/notify/ciscospark.py b/homeassistant/components/notify/ciscospark.py index 3a4ef1384d9..ee6115c3f79 100644 --- a/homeassistant/components/notify/ciscospark.py +++ b/homeassistant/components/notify/ciscospark.py @@ -5,17 +5,19 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/notify.ciscospark/ """ import logging + import voluptuous as vol + from homeassistant.components.notify import ( PLATFORM_SCHEMA, BaseNotificationService, ATTR_TITLE) from homeassistant.const import (CONF_TOKEN) import homeassistant.helpers.config_validation as cv -CONF_ROOMID = "roomid" +REQUIREMENTS = ['ciscosparkapi==0.4.2'] _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['ciscosparkapi==0.4.2'] +CONF_ROOMID = 'roomid' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_TOKEN): cv.string, diff --git a/homeassistant/components/sensor/api_streams.py b/homeassistant/components/sensor/api_streams.py index e1d6c775196..c15ca41d2bf 100644 --- a/homeassistant/components/sensor/api_streams.py +++ b/homeassistant/components/sensor/api_streams.py @@ -1,4 +1,9 @@ -"""Entity to track connections to stream API.""" +""" +Entity to track connections to stream API. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.api_stream/ +""" import asyncio import logging @@ -6,7 +11,6 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.core import callback from homeassistant.helpers.entity import Entity - NAME_WS = 'homeassistant.components.websocket_api' NAME_STREAM = 'homeassistant.components.api' @@ -46,7 +50,7 @@ class StreamHandler(logging.Handler): @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): - """Set up the logger for filters.""" + """Set up the API stream platform.""" entity = APICount() handler = StreamHandler(entity) diff --git a/homeassistant/components/sensor/blink.py b/homeassistant/components/sensor/blink.py index 738f8cb2768..e069dfa00f7 100644 --- a/homeassistant/components/sensor/blink.py +++ b/homeassistant/components/sensor/blink.py @@ -10,18 +10,19 @@ from homeassistant.components.blink import DOMAIN from homeassistant.const import TEMP_FAHRENHEIT from homeassistant.helpers.entity import Entity +_LOGGER = logging.getLogger(__name__) + DEPENDENCIES = ['blink'] + SENSOR_TYPES = { 'temperature': ['Temperature', TEMP_FAHRENHEIT], 'battery': ['Battery', ''], 'notifications': ['Notifications', ''] } -_LOGGER = logging.getLogger(__name__) - def setup_platform(hass, config, add_devices, discovery_info=None): - """Setup a Blink sensor.""" + """Set up a Blink sensor.""" if discovery_info is None: return diff --git a/homeassistant/components/sensor/ring.py b/homeassistant/components/sensor/ring.py index ab64557dd2f..7c342a75f13 100644 --- a/homeassistant/components/sensor/ring.py +++ b/homeassistant/components/sensor/ring.py @@ -8,15 +8,15 @@ import logging from datetime import timedelta import voluptuous as vol -import homeassistant.helpers.config_validation as cv +import homeassistant.loader as loader +import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, CONF_SCAN_INTERVAL, CONF_USERNAME, CONF_PASSWORD, STATE_UNKNOWN, ATTR_ATTRIBUTION) from homeassistant.helpers.entity import Entity -import homeassistant.loader as loader from requests.exceptions import HTTPError, ConnectTimeout diff --git a/homeassistant/components/tado.py b/homeassistant/components/tado.py index b0aae8b3f4a..ffb4da61fed 100644 --- a/homeassistant/components/tado.py +++ b/homeassistant/components/tado.py @@ -1,31 +1,31 @@ """ -Support for the (unofficial) tado api. +Support for the (unofficial) Tado api. For more details about this component, please refer to the documentation at https://home-assistant.io/components/tado/ """ - import logging import urllib - from datetime import timedelta + import voluptuous as vol from homeassistant.helpers.discovery import load_platform from homeassistant.helpers import config_validation as cv -from homeassistant.const import ( - CONF_USERNAME, CONF_PASSWORD) +from homeassistant.const import CONF_USERNAME, CONF_PASSWORD from homeassistant.util import Throttle - -_LOGGER = logging.getLogger(__name__) - -DOMAIN = 'tado' - REQUIREMENTS = ['https://github.com/wmalgadey/PyTado/archive/' '0.1.10.zip#' 'PyTado==0.1.10'] +_LOGGER = logging.getLogger(__name__) + +DATA_TADO = 'tado_data' +DOMAIN = 'tado' + +MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10) + TADO_COMPONENTS = [ 'sensor', 'climate' ] @@ -37,13 +37,9 @@ CONFIG_SCHEMA = vol.Schema({ }) }, extra=vol.ALLOW_EXTRA) -MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10) - -DATA_TADO = 'tado_data' - def setup(hass, config): - """Your controller/hub specific code.""" + """Set up of the Tado component.""" username = config[DOMAIN][CONF_USERNAME] password = config[DOMAIN][CONF_PASSWORD] @@ -64,7 +60,7 @@ def setup(hass, config): class TadoDataStore: - """An object to store the tado data.""" + """An object to store the Tado data.""" def __init__(self, tado): """Initialize Tado data store.""" @@ -80,19 +76,19 @@ class TadoDataStore: data = None try: - if "zone" in sensor: - _LOGGER.info("querying mytado.com for zone %s %s", - sensor["id"], sensor["name"]) - data = self.tado.getState(sensor["id"]) + if 'zone' in sensor: + _LOGGER.info("Querying mytado.com for zone %s %s", + sensor['id'], sensor['name']) + data = self.tado.getState(sensor['id']) - if "device" in sensor: - _LOGGER.info("querying mytado.com for device %s %s", - sensor["id"], sensor["name"]) + if 'device' in sensor: + _LOGGER.info("Querying mytado.com for device %s %s", + sensor['id'], sensor['name']) data = self.tado.getDevices()[0] except RuntimeError: _LOGGER.error("Unable to connect to myTado. %s %s", - sensor["id"], sensor["id"]) + sensor['id'], sensor['id']) self.data[data_id] = data @@ -103,7 +99,7 @@ class TadoDataStore: def get_data(self, data_id): """Get the cached data.""" - data = {"error": "no data"} + data = {'error': 'no data'} if data_id in self.data: data = self.data[data_id] diff --git a/homeassistant/components/twilio.py b/homeassistant/components/twilio.py index e4b36d41e14..9f32a44ce7e 100644 --- a/homeassistant/components/twilio.py +++ b/homeassistant/components/twilio.py @@ -5,21 +5,25 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/twilio/ """ import voluptuous as vol + import homeassistant.helpers.config_validation as cv from homeassistant.core import callback from homeassistant.components.http import HomeAssistantView -DEPENDENCIES = ['http'] REQUIREMENTS = ['twilio==5.7.0'] DOMAIN = 'twilio' -DATA_TWILIO = DOMAIN + API_PATH = '/api/{}'.format(DOMAIN) -RECEIVED_DATA = '{}_data_received'.format(DOMAIN) CONF_ACCOUNT_SID = 'account_sid' CONF_AUTH_TOKEN = 'auth_token' +DATA_TWILIO = DOMAIN +DEPENDENCIES = ['http'] + +RECEIVED_DATA = '{}_data_received'.format(DOMAIN) + CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_ACCOUNT_SID): cv.string, @@ -32,8 +36,8 @@ def setup(hass, config): """Set up the Twilio component.""" from twilio.rest import TwilioRestClient conf = config[DOMAIN] - hass.data[DATA_TWILIO] = TwilioRestClient(conf.get(CONF_ACCOUNT_SID), - conf.get(CONF_AUTH_TOKEN)) + hass.data[DATA_TWILIO] = TwilioRestClient( + conf.get(CONF_ACCOUNT_SID), conf.get(CONF_AUTH_TOKEN)) hass.http.register_view(TwilioReceiveDataView()) return True