Migrate to voluptuous (#2901)
This commit is contained in:
parent
e8c6e4d561
commit
18fd17fdf3
2 changed files with 22 additions and 11 deletions
|
@ -6,26 +6,37 @@ https://home-assistant.io/components/light.blinksticklight/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
|
from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
|
||||||
Light)
|
Light, PLATFORM_SCHEMA)
|
||||||
|
from homeassistant.const import CONF_NAME
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
CONF_SERIAL = 'serial'
|
||||||
|
DEFAULT_NAME = 'Blinkstick'
|
||||||
|
REQUIREMENTS = ["blinkstick==1.1.8"]
|
||||||
|
SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_SERIAL): cv.string,
|
||||||
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS = ["blinkstick==1.1.7"]
|
|
||||||
|
|
||||||
|
|
||||||
SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Add device specified by serial number."""
|
"""Add device specified by serial number."""
|
||||||
from blinkstick import blinkstick
|
from blinkstick import blinkstick
|
||||||
|
|
||||||
stick = blinkstick.find_by_serial(config['serial'])
|
name = config.get(CONF_NAME)
|
||||||
|
serial = config.get(CONF_SERIAL)
|
||||||
|
|
||||||
add_devices_callback([BlinkStickLight(stick, config['name'])])
|
stick = blinkstick.find_by_serial(serial)
|
||||||
|
|
||||||
|
add_devices([BlinkStickLight(stick, name)])
|
||||||
|
|
||||||
|
|
||||||
class BlinkStickLight(Light):
|
class BlinkStickLight(Light):
|
||||||
|
|
|
@ -35,7 +35,7 @@ apcaccess==0.0.4
|
||||||
astral==1.2
|
astral==1.2
|
||||||
|
|
||||||
# homeassistant.components.light.blinksticklight
|
# homeassistant.components.light.blinksticklight
|
||||||
blinkstick==1.1.7
|
blinkstick==1.1.8
|
||||||
|
|
||||||
# homeassistant.components.sensor.bitcoin
|
# homeassistant.components.sensor.bitcoin
|
||||||
blockchain==1.3.3
|
blockchain==1.3.3
|
||||||
|
|
Loading…
Add table
Reference in a new issue