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
This commit is contained in:
Fabian Affolter 2017-03-26 15:50:40 +02:00 committed by GitHub
parent 22b28d85db
commit 5d5547cdb6
14 changed files with 160 additions and 192 deletions

View File

@ -11,7 +11,7 @@ DEPENDENCIES = ['blink']
def setup_platform(hass, config, add_devices, discovery_info=None): 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: if discovery_info is None:
return return

View File

@ -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 asyncio
import logging import logging
import datetime import datetime
@ -6,8 +11,8 @@ import datetime
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (STATE_ON, STATE_OFF, STATE_UNKNOWN, from homeassistant.const import (
CONF_NAME, WEEKDAYS) STATE_ON, STATE_OFF, STATE_UNKNOWN, CONF_NAME, WEEKDAYS)
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
import homeassistant.helpers.config_validation as cv 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): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Workday sensor.""" """Set up the Workday sensor."""
import holidays import holidays
# Get the Sensor name from the config
sensor_name = config.get(CONF_NAME) sensor_name = config.get(CONF_NAME)
# Get the country code from the config
country = config.get(CONF_COUNTRY) country = config.get(CONF_COUNTRY)
# Get the province from the config
province = config.get(CONF_PROVINCE) province = config.get(CONF_PROVINCE)
# Get the list of workdays from the config
workdays = config.get(CONF_WORKDAYS) workdays = config.get(CONF_WORKDAYS)
# Get the list of excludes from the config
excludes = config.get(CONF_EXCLUDES) excludes = config.get(CONF_EXCLUDES)
# Instantiate the holidays module for the current year
year = datetime.datetime.now().year year = datetime.datetime.now().year
obj_holidays = getattr(holidays, country)(years=year) obj_holidays = getattr(holidays, country)(years=year)
# Also apply the provience, if available for the configured country
if province: if province:
if province not in obj_holidays.PROVINCES: if province not in obj_holidays.PROVINCES:
_LOGGER.error('There is no province/state %s in country %s', _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, obj_holidays = getattr(holidays, country)(prov=province,
years=year) years=year)
# Output found public holidays via the debug channel
_LOGGER.debug("Found the following holidays for your configuration:") _LOGGER.debug("Found the following holidays for your configuration:")
for date, name in sorted(obj_holidays.items()): for date, name in sorted(obj_holidays.items()):
_LOGGER.debug("%s %s", date, name) _LOGGER.debug("%s %s", date, name)
# Add ourselves as device add_devices([IsWorkdaySensor(
add_devices([IsWorkdaySensor(obj_holidays, workdays, obj_holidays, workdays, excludes, sensor_name)], True)
excludes, sensor_name)], True)
def day_to_string(day): def day_to_string(day):
@ -122,7 +114,6 @@ class IsWorkdaySensor(Entity):
def is_include(self, day, now): def is_include(self, day, now):
"""Check if given day is in the includes list.""" """Check if given day is in the includes list."""
# Check includes
if day in self._workdays: if day in self._workdays:
return True return True
elif 'holiday' in self._workdays and now in self._obj_holidays: elif 'holiday' in self._workdays and now in self._obj_holidays:
@ -132,7 +123,6 @@ class IsWorkdaySensor(Entity):
def is_exclude(self, day, now): def is_exclude(self, day, now):
"""Check if given day is in the excludes list.""" """Check if given day is in the excludes list."""
# Check excludes
if day in self._excludes: if day in self._excludes:
return True return True
elif 'holiday' in self._excludes and now in self._obj_holidays: elif 'holiday' in self._excludes and now in self._obj_holidays:

View File

@ -5,17 +5,19 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/blink/ https://home-assistant.io/components/blink/
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.const import (CONF_USERNAME, from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, CONF_PASSWORD, ATTR_FRIENDLY_NAME, ATTR_ARMED)
ATTR_FRIENDLY_NAME,
ATTR_ARMED)
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
REQUIREMENTS = ['blinkpy==0.5.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DOMAIN = 'blink' DOMAIN = 'blink'
REQUIREMENTS = ['blinkpy==0.5.2']
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({ DOMAIN: vol.Schema({
@ -50,7 +52,7 @@ class BlinkSystem(object):
def setup(hass, config): def setup(hass, config):
"""Setup Blink System.""" """Set up Blink System."""
hass.data[DOMAIN] = BlinkSystem(config) hass.data[DOMAIN] = BlinkSystem(config)
discovery.load_platform(hass, 'camera', DOMAIN, {}, config) discovery.load_platform(hass, 'camera', DOMAIN, {}, config)
discovery.load_platform(hass, 'sensor', 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.arm = value
hass.data[DOMAIN].blink.refresh() hass.data[DOMAIN].blink.refresh()
hass.services.register(DOMAIN, 'snap_picture', snap_picture, hass.services.register(
schema=SNAP_PICTURE_SCHEMA) DOMAIN, 'snap_picture', snap_picture, schema=SNAP_PICTURE_SCHEMA)
hass.services.register(DOMAIN, 'arm_camera', arm_camera, hass.services.register(
schema=ARM_CAMERA_SCHEMA) DOMAIN, 'arm_camera', arm_camera, schema=ARM_CAMERA_SCHEMA)
hass.services.register(DOMAIN, 'arm_system', arm_system, hass.services.register(
schema=ARM_SYSTEM_SCHEMA) DOMAIN, 'arm_system', arm_system, schema=ARM_SYSTEM_SCHEMA)
return True return True

View File

@ -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 import logging
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate import ( from homeassistant.const import ATTR_TEMPERATURE
ClimateDevice) from homeassistant.components.tado import DATA_TADO
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"}
_LOGGER = logging.getLogger(__name__) _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): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the climate platform.""" """Set up the Tado climate platform."""
# get the PyTado object from the hub component
tado = hass.data[DATA_TADO] tado = hass.data[DATA_TADO]
try: try:
@ -45,10 +45,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
climate_devices = [] climate_devices = []
for zone in zones: for zone in zones:
climate_devices.append(create_climate_device(tado, hass, climate_devices.append(create_climate_device(
zone, tado, hass, zone, zone['name'], zone['id']))
zone['name'],
zone['id']))
if len(climate_devices) > 0: if len(climate_devices) > 0:
add_devices(climate_devices, True) 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): 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) capabilities = tado.get_capabilities(zone_id)
unit = TEMP_CELSIUS unit = TEMP_CELSIUS
min_temp = float(capabilities["temperatures"]["celsius"]["min"]) min_temp = float(capabilities['temperatures']['celsius']['min'])
max_temp = float(capabilities["temperatures"]["celsius"]["max"]) max_temp = float(capabilities['temperatures']['celsius']['max'])
ac_mode = capabilities["type"] != "HEATING" ac_mode = capabilities['type'] != 'HEATING'
data_id = 'zone {} {}'.format(name, zone_id) data_id = 'zone {} {}'.format(name, zone_id)
device = TadoClimate(tado, device = TadoClimate(tado,
@ -74,10 +72,10 @@ def create_climate_device(tado, hass, zone, name, zone_id):
ac_mode) ac_mode)
tado.add_sensor(data_id, { tado.add_sensor(data_id, {
"id": zone_id, 'id': zone_id,
"zone": zone, 'zone': zone,
"name": name, 'name': name,
"climate": device 'climate': device
}) })
return device return device
@ -89,7 +87,7 @@ class TadoClimate(ClimateDevice):
def __init__(self, store, zone_name, zone_id, data_id, def __init__(self, store, zone_name, zone_id, data_id,
min_temp, max_temp, ac_mode, min_temp, max_temp, ac_mode,
tolerance=0.3): tolerance=0.3):
"""Initialization of TadoClimate device.""" """Initialization of Tado climate device."""
self._store = store self._store = store
self._data_id = data_id self._data_id = data_id
@ -202,8 +200,7 @@ class TadoClimate(ClimateDevice):
data = self._store.get_data(self._data_id) data = self._store.get_data(self._data_id)
if data is None: if data is None:
_LOGGER.debug('Recieved no data for zone %s', _LOGGER.debug("Recieved no data for zone %s", self.zone_name)
self.zone_name)
return return
if 'sensorDataPoints' in data: if 'sensorDataPoints' in data:
@ -232,11 +229,11 @@ class TadoClimate(ClimateDevice):
if 'tadoMode' in data: if 'tadoMode' in data:
mode = data['tadoMode'] mode = data['tadoMode']
self._is_away = mode == "AWAY" self._is_away = mode == 'AWAY'
if 'setting' in data: if 'setting' in data:
power = data['setting']['power'] power = data['setting']['power']
if power == "OFF": if power == 'OFF':
self._current_operation = CONST_MODE_OFF self._current_operation = CONST_MODE_OFF
self._device_is_active = False self._device_is_active = False
else: else:
@ -249,48 +246,47 @@ class TadoClimate(ClimateDevice):
overlay = False overlay = False
termination = "" termination = ""
# if you set mode manualy to off, there will be an overlay # If you set mode manualy to off, there will be an overlay
# and a termination, but we want to see the mode "OFF" # and a termination, but we want to see the mode "OFF"
if overlay and self._device_is_active: 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._overlay_mode = termination
self._current_operation = termination self._current_operation = termination
else: else:
# there is no overlay, the mode will always be # There is no overlay, the mode will always be
# "SMART_SCHEDULE" # "SMART_SCHEDULE"
self._overlay_mode = CONST_MODE_SMART_SCHEDULE self._overlay_mode = CONST_MODE_SMART_SCHEDULE
self._current_operation = CONST_MODE_SMART_SCHEDULE self._current_operation = CONST_MODE_SMART_SCHEDULE
def _control_heating(self): def _control_heating(self):
"""Send new target temperature to mytado.""" """Send new target temperature to mytado."""
if not self._active and None not in (self._cur_temp, if not self._active and None not in (
self._target_temp): self._cur_temp, self._target_temp):
self._active = True self._active = True
_LOGGER.info('Obtained current and target temperature. ' _LOGGER.info("Obtained current and target temperature. "
'tado thermostat active.') "Tado thermostat active")
if not self._active or self._current_operation == self._overlay_mode: if not self._active or self._current_operation == self._overlay_mode:
return return
if self._current_operation == CONST_MODE_SMART_SCHEDULE: if self._current_operation == CONST_MODE_SMART_SCHEDULE:
_LOGGER.info('Switching mytado.com to SCHEDULE (default) ' _LOGGER.info("Switching mytado.com to SCHEDULE (default) "
'for zone %s', self.zone_name) "for zone %s", self.zone_name)
self._store.reset_zone_overlay(self.zone_id) self._store.reset_zone_overlay(self.zone_id)
self._overlay_mode = self._current_operation self._overlay_mode = self._current_operation
return return
if self._current_operation == CONST_MODE_OFF: 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.zone_name)
self._store.set_zone_overlay(self.zone_id, CONST_OVERLAY_MANUAL) self._store.set_zone_overlay(self.zone_id, CONST_OVERLAY_MANUAL)
self._overlay_mode = self._current_operation self._overlay_mode = self._current_operation
return 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._current_operation, self.zone_name)
self._store.set_zone_overlay(self.zone_id, self._store.set_zone_overlay(
self._current_operation, self.zone_id, self._current_operation, self._target_temp)
self._target_temp)
self._overlay_mode = self._current_operation self._overlay_mode = self._current_operation

View File

@ -9,15 +9,12 @@ import subprocess
import voluptuous as vol 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 ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
Light, PLATFORM_SCHEMA) Light, PLATFORM_SCHEMA)
from homeassistant.const import CONF_NAME 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'] REQUIREMENTS = ['piglow==1.2.4']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -32,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Piglow Light platform.""" """Set up the Piglow Light platform."""
import piglow import piglow
if subprocess.getoutput("i2cdetect -q -y 1 | grep -o 54") != '54': 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) name = config.get(CONF_NAME)
# Add devices
add_devices([PiglowLight(piglow, name)]) add_devices([PiglowLight(piglow, name)])

View File

@ -5,21 +5,19 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.yeelightsunflower/ https://home-assistant.io/components/light.yeelightsunflower/
""" """
import logging import logging
import voluptuous as vol 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 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'] REQUIREMENTS = ['yeelightsunflower==0.0.8']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR) SUPPORT_YEELIGHT_SUNFLOWER = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@ -35,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hub = yeelightsunflower.Hub(host) hub = yeelightsunflower.Hub(host)
if not hub.available: if not hub.available:
_LOGGER.error('Could not connect to Yeelight Sunflower hub') _LOGGER.error("Could not connect to Yeelight Sunflower hub")
return False return False
add_devices(SunflowerBulb(light) for light in hub.get_lights()) add_devices(SunflowerBulb(light) for light in hub.get_lights())
@ -55,7 +53,7 @@ class SunflowerBulb(Light):
@property @property
def name(self): def name(self):
"""Return the display name of this light.""" """Return the display name of this light."""
return "sunflower_{}".format(self._light.zid) return 'sunflower_{}'.format(self._light.zid)
@property @property
def available(self): def available(self):

View File

@ -42,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Frontier Silicon platform.""" """Set up the Frontier Silicon platform."""
import requests import requests
if discovery_info is not None: if discovery_info is not None:
@ -59,10 +59,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices( add_devices(
[FSAPIDevice(DEVICE_URL.format(host, port), password)], [FSAPIDevice(DEVICE_URL.format(host, port), password)],
update_before_add=True) 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 return True
except requests.exceptions.RequestException: 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) host, port, password)
return False return False

View File

@ -1,49 +1,31 @@
""" """
Volumio Platform. Volumio Platform.
The volumio platform allows you to control a Volumio media player For more details about this platform, please refer to the documentation at
from Home Assistant. https://home-assistant.io/components/media_player.volumio/
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
""" """
import logging import logging
import asyncio import asyncio
import aiohttp import aiohttp
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK,
SUPPORT_PREVIOUS_TRACK, SUPPORT_SEEK, SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_STOP,
SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA, MEDIA_TYPE_MUSIC)
SUPPORT_VOLUME_SET, SUPPORT_STOP,
SUPPORT_PLAY, MediaPlayerDevice,
PLATFORM_SCHEMA, MEDIA_TYPE_MUSIC)
from homeassistant.const import ( from homeassistant.const import (
STATE_PLAYING, STATE_PAUSED, STATE_IDLE, CONF_HOST, CONF_PORT, CONF_NAME) STATE_PLAYING, STATE_PAUSED, STATE_IDLE, CONF_HOST, CONF_PORT, CONF_NAME)
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
_CONFIGURING = {} _CONFIGURING = {}
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEFAULT_HOST = 'localhost' DEFAULT_HOST = 'localhost'
DEFAULT_NAME = 'Volumio' DEFAULT_NAME = 'Volumio'
DEFAULT_PORT = 3000 DEFAULT_PORT = 3000
TIMEOUT = 10 TIMEOUT = 10
SUPPORT_VOLUMIO = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ SUPPORT_VOLUMIO = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
@ -60,10 +42,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@asyncio.coroutine @asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None): 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) host = config.get(CONF_HOST)
port = config.get(CONF_PORT) port = config.get(CONF_PORT)
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
async_add_devices([Volumio(name, host, port, hass)]) async_add_devices([Volumio(name, host, port, hass)])
@ -75,7 +58,7 @@ class Volumio(MediaPlayerDevice):
self.host = host self.host = host
self.port = port self.port = port
self.hass = hass self.hass = hass
self._url = host + ":" + str(port) self._url = '{}:{}'.format(host, str(port))
self._name = name self._name = name
self._state = {} self._state = {}
self.async_update() self.async_update()
@ -84,8 +67,7 @@ class Volumio(MediaPlayerDevice):
@asyncio.coroutine @asyncio.coroutine
def send_volumio_msg(self, method, params=None): def send_volumio_msg(self, method, params=None):
"""Send message.""" """Send message."""
url = "http://{}:{}/api/v1/{}/".format( url = "http://{}:{}/api/v1/{}/".format(self.host, self.port, method)
self.host, self.port, method)
response = None response = None
_LOGGER.debug("URL: %s params: %s", url, params) _LOGGER.debug("URL: %s params: %s", url, params)
@ -218,9 +200,8 @@ class Volumio(MediaPlayerDevice):
def async_set_volume_level(self, volume): def async_set_volume_level(self, volume):
"""Send volume_up command to media player.""" """Send volume_up command to media player."""
return self.send_volumio_msg('commands', return self.send_volumio_msg(
params={'cmd': 'volume', 'commands', params={'cmd': 'volume', 'volume': int(volume * 100)})
'volume': int(volume * 100)})
def async_mute_volume(self, mute): def async_mute_volume(self, mute):
"""Send mute command to media player.""" """Send mute command to media player."""
@ -228,10 +209,8 @@ class Volumio(MediaPlayerDevice):
if mute: if mute:
# mute is implemenhted as 0 volume, do save last volume level # mute is implemenhted as 0 volume, do save last volume level
self._lastvol = self._state['volume'] self._lastvol = self._state['volume']
return self.send_volumio_msg('commands', return self.send_volumio_msg(
params={'cmd': 'volume', 'commands', params={'cmd': 'volume', 'volume': mutecmd})
'volume': mutecmd})
else: else:
return self.send_volumio_msg('commands', return self.send_volumio_msg(
params={'cmd': 'volume', 'commands', params={'cmd': 'volume', 'volume': self._lastvol})
'volume': self._lastvol})

View File

@ -5,17 +5,19 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/notify.ciscospark/ https://home-assistant.io/components/notify.ciscospark/
""" """
import logging import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.notify import ( from homeassistant.components.notify import (
PLATFORM_SCHEMA, BaseNotificationService, ATTR_TITLE) PLATFORM_SCHEMA, BaseNotificationService, ATTR_TITLE)
from homeassistant.const import (CONF_TOKEN) from homeassistant.const import (CONF_TOKEN)
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
CONF_ROOMID = "roomid" REQUIREMENTS = ['ciscosparkapi==0.4.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['ciscosparkapi==0.4.2'] CONF_ROOMID = 'roomid'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_TOKEN): cv.string, vol.Required(CONF_TOKEN): cv.string,

View File

@ -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 asyncio
import logging import logging
@ -6,7 +11,6 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
NAME_WS = 'homeassistant.components.websocket_api' NAME_WS = 'homeassistant.components.websocket_api'
NAME_STREAM = 'homeassistant.components.api' NAME_STREAM = 'homeassistant.components.api'
@ -46,7 +50,7 @@ class StreamHandler(logging.Handler):
@asyncio.coroutine @asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None): 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() entity = APICount()
handler = StreamHandler(entity) handler = StreamHandler(entity)

View File

@ -10,18 +10,19 @@ from homeassistant.components.blink import DOMAIN
from homeassistant.const import TEMP_FAHRENHEIT from homeassistant.const import TEMP_FAHRENHEIT
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['blink'] DEPENDENCIES = ['blink']
SENSOR_TYPES = { SENSOR_TYPES = {
'temperature': ['Temperature', TEMP_FAHRENHEIT], 'temperature': ['Temperature', TEMP_FAHRENHEIT],
'battery': ['Battery', ''], 'battery': ['Battery', ''],
'notifications': ['Notifications', ''] 'notifications': ['Notifications', '']
} }
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup a Blink sensor.""" """Set up a Blink sensor."""
if discovery_info is None: if discovery_info is None:
return return

View File

@ -8,15 +8,15 @@ import logging
from datetime import timedelta from datetime import timedelta
import voluptuous as vol 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.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ( from homeassistant.const import (
CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, CONF_SCAN_INTERVAL, CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, CONF_SCAN_INTERVAL,
CONF_USERNAME, CONF_PASSWORD, STATE_UNKNOWN, CONF_USERNAME, CONF_PASSWORD, STATE_UNKNOWN,
ATTR_ATTRIBUTION) ATTR_ATTRIBUTION)
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
import homeassistant.loader as loader
from requests.exceptions import HTTPError, ConnectTimeout from requests.exceptions import HTTPError, ConnectTimeout

View File

@ -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 For more details about this component, please refer to the documentation at
https://home-assistant.io/components/tado/ https://home-assistant.io/components/tado/
""" """
import logging import logging
import urllib import urllib
from datetime import timedelta from datetime import timedelta
import voluptuous as vol import voluptuous as vol
from homeassistant.helpers.discovery import load_platform from homeassistant.helpers.discovery import load_platform
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.const import ( from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
CONF_USERNAME, CONF_PASSWORD)
from homeassistant.util import Throttle from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
DOMAIN = 'tado'
REQUIREMENTS = ['https://github.com/wmalgadey/PyTado/archive/' REQUIREMENTS = ['https://github.com/wmalgadey/PyTado/archive/'
'0.1.10.zip#' '0.1.10.zip#'
'PyTado==0.1.10'] 'PyTado==0.1.10']
_LOGGER = logging.getLogger(__name__)
DATA_TADO = 'tado_data'
DOMAIN = 'tado'
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)
TADO_COMPONENTS = [ TADO_COMPONENTS = [
'sensor', 'climate' 'sensor', 'climate'
] ]
@ -37,13 +37,9 @@ CONFIG_SCHEMA = vol.Schema({
}) })
}, extra=vol.ALLOW_EXTRA) }, extra=vol.ALLOW_EXTRA)
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=10)
DATA_TADO = 'tado_data'
def setup(hass, config): def setup(hass, config):
"""Your controller/hub specific code.""" """Set up of the Tado component."""
username = config[DOMAIN][CONF_USERNAME] username = config[DOMAIN][CONF_USERNAME]
password = config[DOMAIN][CONF_PASSWORD] password = config[DOMAIN][CONF_PASSWORD]
@ -64,7 +60,7 @@ def setup(hass, config):
class TadoDataStore: class TadoDataStore:
"""An object to store the tado data.""" """An object to store the Tado data."""
def __init__(self, tado): def __init__(self, tado):
"""Initialize Tado data store.""" """Initialize Tado data store."""
@ -80,19 +76,19 @@ class TadoDataStore:
data = None data = None
try: try:
if "zone" in sensor: if 'zone' in sensor:
_LOGGER.info("querying mytado.com for zone %s %s", _LOGGER.info("Querying mytado.com for zone %s %s",
sensor["id"], sensor["name"]) sensor['id'], sensor['name'])
data = self.tado.getState(sensor["id"]) data = self.tado.getState(sensor['id'])
if "device" in sensor: if 'device' in sensor:
_LOGGER.info("querying mytado.com for device %s %s", _LOGGER.info("Querying mytado.com for device %s %s",
sensor["id"], sensor["name"]) sensor['id'], sensor['name'])
data = self.tado.getDevices()[0] data = self.tado.getDevices()[0]
except RuntimeError: except RuntimeError:
_LOGGER.error("Unable to connect to myTado. %s %s", _LOGGER.error("Unable to connect to myTado. %s %s",
sensor["id"], sensor["id"]) sensor['id'], sensor['id'])
self.data[data_id] = data self.data[data_id] = data
@ -103,7 +99,7 @@ class TadoDataStore:
def get_data(self, data_id): def get_data(self, data_id):
"""Get the cached data.""" """Get the cached data."""
data = {"error": "no data"} data = {'error': 'no data'}
if data_id in self.data: if data_id in self.data:
data = self.data[data_id] data = self.data[data_id]

View File

@ -5,21 +5,25 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/twilio/ https://home-assistant.io/components/twilio/
""" """
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.components.http import HomeAssistantView from homeassistant.components.http import HomeAssistantView
DEPENDENCIES = ['http']
REQUIREMENTS = ['twilio==5.7.0'] REQUIREMENTS = ['twilio==5.7.0']
DOMAIN = 'twilio' DOMAIN = 'twilio'
DATA_TWILIO = DOMAIN
API_PATH = '/api/{}'.format(DOMAIN) API_PATH = '/api/{}'.format(DOMAIN)
RECEIVED_DATA = '{}_data_received'.format(DOMAIN)
CONF_ACCOUNT_SID = 'account_sid' CONF_ACCOUNT_SID = 'account_sid'
CONF_AUTH_TOKEN = 'auth_token' CONF_AUTH_TOKEN = 'auth_token'
DATA_TWILIO = DOMAIN
DEPENDENCIES = ['http']
RECEIVED_DATA = '{}_data_received'.format(DOMAIN)
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({ DOMAIN: vol.Schema({
vol.Required(CONF_ACCOUNT_SID): cv.string, vol.Required(CONF_ACCOUNT_SID): cv.string,
@ -32,8 +36,8 @@ def setup(hass, config):
"""Set up the Twilio component.""" """Set up the Twilio component."""
from twilio.rest import TwilioRestClient from twilio.rest import TwilioRestClient
conf = config[DOMAIN] conf = config[DOMAIN]
hass.data[DATA_TWILIO] = TwilioRestClient(conf.get(CONF_ACCOUNT_SID), hass.data[DATA_TWILIO] = TwilioRestClient(
conf.get(CONF_AUTH_TOKEN)) conf.get(CONF_ACCOUNT_SID), conf.get(CONF_AUTH_TOKEN))
hass.http.register_view(TwilioReceiveDataView()) hass.http.register_view(TwilioReceiveDataView())
return True return True