From 160b811ddfc71c58e2e9e986fad41c7633089b31 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 8 Feb 2016 08:53:22 -0800 Subject: [PATCH] Wink light to inherit from light --- homeassistant/components/light/wink.py | 31 +++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index db545dbe240..6b7bb1afcec 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -8,8 +8,7 @@ https://home-assistant.io/components/light.wink/ """ import logging -from homeassistant.components.light import ATTR_BRIGHTNESS -from homeassistant.components.wink import WinkToggleDevice +from homeassistant.components.light import ATTR_BRIGHTNESS, Light from homeassistant.const import CONF_ACCESS_TOKEN REQUIREMENTS = ['python-wink==0.5.0'] @@ -34,9 +33,27 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): WinkLight(light) for light in pywink.get_bulbs()) -class WinkLight(WinkToggleDevice): +class WinkLight(Light): """ Represents a Wink light. """ + def __init__(self, wink): + self.wink = wink + + @property + def unique_id(self): + """ Returns the id of this Wink switch. """ + return "{}.{}".format(self.__class__, self.wink.device_id()) + + @property + def name(self): + """ Returns the name of the light if any. """ + return self.wink.name() + + @property + def is_on(self): + """ True if light is on. """ + return self.wink.state() + @property def brightness(self): """Brightness of the light.""" @@ -52,3 +69,11 @@ class WinkLight(WinkToggleDevice): else: self.wink.set_state(True) + + def turn_off(self): + """ Turns the switch off. """ + self.wink.set_state(False) + + def update(self): + """ Update state of the light. """ + self.wink.update_state()