Fix PEP8 and PEP257 issues (#11780)

This commit is contained in:
Fabian Affolter 2018-01-19 07:36:29 +01:00 committed by Paulus Schoutsen
parent 48619c9d7c
commit 7fe2dafa04
5 changed files with 22 additions and 27 deletions

View File

@ -4,7 +4,6 @@ Support for deCONZ binary sensor.
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/binary_sensor.deconz/ https://home-assistant.io/components/binary_sensor.deconz/
""" """
import asyncio import asyncio
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
@ -17,7 +16,7 @@ DEPENDENCIES = ['deconz']
@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 binary sensor for deCONZ component.""" """Set up the deCONZ binary sensor."""
if discovery_info is None: if discovery_info is None:
return return
@ -36,7 +35,7 @@ class DeconzBinarySensor(BinarySensorDevice):
"""Representation of a binary sensor.""" """Representation of a binary sensor."""
def __init__(self, sensor): def __init__(self, sensor):
"""Setup sensor and add update callback to get data from websocket.""" """Set up sensor and add update callback to get data from websocket."""
self._sensor = sensor self._sensor = sensor
@asyncio.coroutine @asyncio.coroutine
@ -68,7 +67,7 @@ class DeconzBinarySensor(BinarySensorDevice):
@property @property
def device_class(self): def device_class(self):
"""Class of the sensor.""" """Return the class of the sensor."""
return self._sensor.sensor_class return self._sensor.sensor_class
@property @property

View File

@ -4,14 +4,14 @@ Support for deCONZ devices.
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/deconz/ https://home-assistant.io/components/deconz/
""" """
import asyncio import asyncio
import logging import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.discovery import SERVICE_DECONZ
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP) CONF_API_KEY, CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP)
from homeassistant.components.discovery import SERVICE_DECONZ
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -27,8 +27,8 @@ CONFIG_FILE = 'deconz.conf'
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({ DOMAIN: vol.Schema({
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_API_KEY): cv.string, vol.Optional(CONF_API_KEY): cv.string,
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_PORT, default=80): cv.port, vol.Optional(CONF_PORT, default=80): cv.port,
}) })
}, extra=vol.ALLOW_EXTRA) }, extra=vol.ALLOW_EXTRA)
@ -53,7 +53,7 @@ Unlock your deCONZ gateway to register with Home Assistant.
@asyncio.coroutine @asyncio.coroutine
def async_setup(hass, config): def async_setup(hass, config):
"""Setup services and configuration for deCONZ component.""" """Set up services and configuration for deCONZ component."""
result = False result = False
config_file = yield from hass.async_add_job( config_file = yield from hass.async_add_job(
load_json, hass.config.path(CONFIG_FILE)) load_json, hass.config.path(CONFIG_FILE))
@ -85,7 +85,7 @@ def async_setup(hass, config):
@asyncio.coroutine @asyncio.coroutine
def async_setup_deconz(hass, config, deconz_config): def async_setup_deconz(hass, config, deconz_config):
"""Setup deCONZ session. """Set up a deCONZ session.
Load config, group, light and sensor data for server information. Load config, group, light and sensor data for server information.
Start websocket for push notification of state changes from deCONZ. Start websocket for push notification of state changes from deCONZ.
@ -147,9 +147,8 @@ def async_request_configuration(hass, config, deconz_config):
deconz_config[CONF_API_KEY] = api_key deconz_config[CONF_API_KEY] = api_key
result = yield from async_setup_deconz(hass, config, deconz_config) result = yield from async_setup_deconz(hass, config, deconz_config)
if result: if result:
yield from hass.async_add_job(save_json, yield from hass.async_add_job(
hass.config.path(CONFIG_FILE), save_json, hass.config.path(CONFIG_FILE), deconz_config)
deconz_config)
configurator.async_request_done(request_id) configurator.async_request_done(request_id)
return return
else: else:

View File

@ -4,15 +4,14 @@ Support for deCONZ light.
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/light.deconz/ https://home-assistant.io/components/light.deconz/
""" """
import asyncio import asyncio
from homeassistant.components.deconz import DOMAIN as DECONZ_DATA from homeassistant.components.deconz import DOMAIN as DECONZ_DATA
from homeassistant.components.light import ( from homeassistant.components.light import (
Light, ATTR_BRIGHTNESS, ATTR_FLASH, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
ATTR_RGB_COLOR, ATTR_TRANSITION, EFFECT_COLORLOOP, FLASH_LONG, FLASH_SHORT, ATTR_TRANSITION, EFFECT_COLORLOOP, FLASH_LONG, FLASH_SHORT,
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, SUPPORT_XY_COLOR) SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, SUPPORT_XY_COLOR, Light)
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.util.color import color_RGB_to_xy from homeassistant.util.color import color_RGB_to_xy
@ -23,7 +22,7 @@ ATTR_LIGHT_GROUP = 'LightGroup'
@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 light for deCONZ component.""" """Set up the deCONZ light."""
if discovery_info is None: if discovery_info is None:
return return
@ -44,7 +43,7 @@ class DeconzLight(Light):
"""Representation of a deCONZ light.""" """Representation of a deCONZ light."""
def __init__(self, light): def __init__(self, light):
"""Setup light and add update callback to get data from websocket.""" """Set up light and add update callback to get data from websocket."""
self._light = light self._light = light
self._features = SUPPORT_BRIGHTNESS self._features = SUPPORT_BRIGHTNESS

View File

@ -4,7 +4,6 @@ Support for deCONZ scenes.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/scene.deconz/ https://home-assistant.io/components/scene.deconz/
""" """
import asyncio import asyncio
from homeassistant.components.deconz import DOMAIN as DECONZ_DATA from homeassistant.components.deconz import DOMAIN as DECONZ_DATA
@ -31,7 +30,7 @@ class DeconzScene(Scene):
"""Representation of a deCONZ scene.""" """Representation of a deCONZ scene."""
def __init__(self, scene): def __init__(self, scene):
"""Setup scene.""" """Set up a scene."""
self._scene = scene self._scene = scene
@asyncio.coroutine @asyncio.coroutine

View File

@ -4,12 +4,11 @@ Support for deCONZ sensor.
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/sensor.deconz/ https://home-assistant.io/components/sensor.deconz/
""" """
import asyncio import asyncio
from homeassistant.components.deconz import DOMAIN as DECONZ_DATA from homeassistant.components.deconz import DOMAIN as DECONZ_DATA
from homeassistant.const import ATTR_BATTERY_LEVEL, CONF_EVENT, CONF_ID from homeassistant.const import ATTR_BATTERY_LEVEL, CONF_EVENT, CONF_ID
from homeassistant.core import callback, EventOrigin from homeassistant.core import EventOrigin, callback
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.util import slugify from homeassistant.util import slugify
@ -21,7 +20,7 @@ ATTR_EVENT_ID = 'event_id'
@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 sensor for deCONZ component.""" """Set up the deCONZ sensors."""
if discovery_info is None: if discovery_info is None:
return return
@ -45,7 +44,7 @@ class DeconzSensor(Entity):
"""Representation of a sensor.""" """Representation of a sensor."""
def __init__(self, sensor): def __init__(self, sensor):
"""Setup sensor and add update callback to get data from websocket.""" """Set up sensor and add update callback to get data from websocket."""
self._sensor = sensor self._sensor = sensor
@asyncio.coroutine @asyncio.coroutine
@ -77,7 +76,7 @@ class DeconzSensor(Entity):
@property @property
def device_class(self): def device_class(self):
"""Class of the sensor.""" """Return the class of the sensor."""
return self._sensor.sensor_class return self._sensor.sensor_class
@property @property
@ -115,7 +114,7 @@ class DeconzBattery(Entity):
def __init__(self, device): def __init__(self, device):
"""Register dispatcher callback for update of battery state.""" """Register dispatcher callback for update of battery state."""
self._device = device self._device = device
self._name = self._device.name + ' Battery Level' self._name = '{} {}'.format(self._device.name, 'Battery Level')
self._device_class = 'battery' self._device_class = 'battery'
self._unit_of_measurement = "%" self._unit_of_measurement = "%"
@ -142,7 +141,7 @@ class DeconzBattery(Entity):
@property @property
def device_class(self): def device_class(self):
"""Class of the sensor.""" """Return the class of the sensor."""
return self._device_class return self._device_class
@property @property