From 18fd17fdf3fd05c3d16a16dd1f7c80fd9b02dca5 Mon Sep 17 00:00:00 2001
From: Fabian Affolter <mail@fabian-affolter.ch>
Date: Sun, 21 Aug 2016 00:41:14 +0200
Subject: [PATCH] Migrate to voluptuous (#2901)

---
 .../components/light/blinksticklight.py       | 29 +++++++++++++------
 requirements_all.txt                          |  2 +-
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/homeassistant/components/light/blinksticklight.py b/homeassistant/components/light/blinksticklight.py
index ad3bb2c6751..627097d47b9 100644
--- a/homeassistant/components/light/blinksticklight.py
+++ b/homeassistant/components/light/blinksticklight.py
@@ -6,26 +6,37 @@ https://home-assistant.io/components/light.blinksticklight/
 """
 import logging
 
-from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
-                                            Light)
-
-_LOGGER = logging.getLogger(__name__)
+import voluptuous as vol
 
+from homeassistant.components.light import (ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
+                                            Light, PLATFORM_SCHEMA)
+from homeassistant.const import CONF_NAME
+import homeassistant.helpers.config_validation as cv
 
-REQUIREMENTS = ["blinkstick==1.1.7"]
+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,
+})
 
-SUPPORT_BLINKSTICK = SUPPORT_RGB_COLOR
+_LOGGER = logging.getLogger(__name__)
 
 
 # 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."""
     from blinkstick import blinkstick
 
-    stick = blinkstick.find_by_serial(config['serial'])
+    name = config.get(CONF_NAME)
+    serial = config.get(CONF_SERIAL)
+
+    stick = blinkstick.find_by_serial(serial)
 
-    add_devices_callback([BlinkStickLight(stick, config['name'])])
+    add_devices([BlinkStickLight(stick, name)])
 
 
 class BlinkStickLight(Light):
diff --git a/requirements_all.txt b/requirements_all.txt
index 52825484870..5b346816455 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -35,7 +35,7 @@ apcaccess==0.0.4
 astral==1.2
 
 # homeassistant.components.light.blinksticklight
-blinkstick==1.1.7
+blinkstick==1.1.8
 
 # homeassistant.components.sensor.bitcoin
 blockchain==1.3.3
-- 
GitLab