From 429367409c0538e936322e5249a4a26764b06415 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Tue, 28 Mar 2017 17:26:43 +0200 Subject: [PATCH] yeelight: adjust supported features on update() (#6799) * yeelight: adjust supported features on update() Earlier we checked for the type only during the initialization, but this won't work when the bulb is disconnected during the init, causing failures to adjust rgb&color temperature even if those should be supported. fixes #6692 * Use reassign instead of OR for updating the supported features --- homeassistant/components/light/yeelight.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/light/yeelight.py b/homeassistant/components/light/yeelight.py index 7e0bd0e253e..65b32786ce7 100644 --- a/homeassistant/components/light/yeelight.py +++ b/homeassistant/components/light/yeelight.py @@ -44,13 +44,14 @@ DEVICE_SCHEMA = vol.Schema({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA}, }) -SUPPORT_YEELIGHT_RGB = (SUPPORT_RGB_COLOR | - SUPPORT_COLOR_TEMP) - SUPPORT_YEELIGHT = (SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_FLASH) +SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT | + SUPPORT_RGB_COLOR | + SUPPORT_COLOR_TEMP) + def _cmd(func): """A wrapper to catch exceptions from the bulb.""" @@ -179,9 +180,6 @@ class YeelightLight(Light): self._bulb_device = yeelight.Bulb(self._ipaddr) self._bulb_device.get_properties() # force init for type - btype = self._bulb_device.bulb_type - if btype == yeelight.BulbType.Color: - self._supported_features |= SUPPORT_YEELIGHT_RGB self._available = True except yeelight.BulbException as ex: self._available = False @@ -203,6 +201,9 @@ class YeelightLight(Light): try: self._bulb.get_properties() + if self._bulb_device.bulb_type == yeelight.BulbType.Color: + self._supported_features = SUPPORT_YEELIGHT_RGB + self._is_on = self._properties.get("power") == "on" bright = self._properties.get("bright", None)