From 62e57456e18997357f0a687cbff04464a9040db1 Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Sat, 11 Mar 2017 13:18:29 -0500 Subject: [PATCH] Wink scene(shortcut) support (#6147) * Wink scene(shortcut) support * Scenes to Scene * Moved wink scenes from switches to scenes * Updated python-wink version --- homeassistant/components/light/wink.py | 4 +++ homeassistant/components/scene/wink.py | 40 ++++++++++++++++++++++++++ homeassistant/components/wink.py | 4 +-- requirements_all.txt | 2 +- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 homeassistant/components/scene/wink.py diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index c89139171bf..26c85f19fa4 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -18,6 +18,8 @@ DEPENDENCIES = ['wink'] SUPPORT_WINK = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR +RGB_MODES = ['hsb', 'rgb'] + def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Wink lights.""" @@ -54,6 +56,8 @@ class WinkLight(WinkDevice, Light): """Current bulb color in RGB.""" if not self.wink.supports_hue_saturation(): return None + elif self.wink.color_model() not in RGB_MODES: + return False else: hue = self.wink.color_hue() saturation = self.wink.color_saturation() diff --git a/homeassistant/components/scene/wink.py b/homeassistant/components/scene/wink.py new file mode 100644 index 00000000000..aef7f375f0d --- /dev/null +++ b/homeassistant/components/scene/wink.py @@ -0,0 +1,40 @@ +""" +Support for Wink scenes. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/scene.wink/ +""" +import logging + +from homeassistant.components.scene import Scene +from homeassistant.components.wink import WinkDevice, DOMAIN + +DEPENDENCIES = ['wink'] +_LOGGER = logging.getLogger(__name__) + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """Setup the Wink platform.""" + import pywink + + for scene in pywink.get_scenes(): + _id = scene.object_id() + scene.name() + if _id not in hass.data[DOMAIN]['unique_ids']: + add_devices([WinkScene(scene, hass)]) + + +class WinkScene(WinkDevice, Scene): + """Representation of a Wink shortcut/scene.""" + + def __init__(self, wink, hass): + """Initialize the Wink device.""" + super().__init__(wink, hass) + + @property + def is_on(self): + """Python-wink will always return False.""" + return self.wink.state() + + def activate(self, **kwargs): + """Activate the scene.""" + self.wink.activate() diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 39256657c45..67cfcc7074d 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -15,7 +15,7 @@ from homeassistant.const import ( from homeassistant.helpers.entity import Entity import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['python-wink==1.1.1', 'pubnubsub-handler==1.0.1'] +REQUIREMENTS = ['python-wink==1.2.1', 'pubnubsub-handler==1.0.1'] _LOGGER = logging.getLogger(__name__) @@ -55,7 +55,7 @@ CONFIG_SCHEMA = vol.Schema({ WINK_COMPONENTS = [ 'binary_sensor', 'sensor', 'light', 'switch', 'lock', 'cover', 'climate', - 'fan', 'alarm_control_panel' + 'fan', 'alarm_control_panel', 'scene' ] diff --git a/requirements_all.txt b/requirements_all.txt index 0f87c998023..1c54fe4d43b 100755 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -615,7 +615,7 @@ python-twitch==1.3.0 python-vlc==1.1.2 # homeassistant.components.wink -python-wink==1.1.1 +python-wink==1.2.1 # homeassistant.components.device_tracker.trackr pytrackr==0.0.5