From 390086bb7ef4988b9f67ef2c518ba022758d923b Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Sun, 15 Apr 2018 00:54:02 -0700 Subject: [PATCH] Eufy colour bulb updates (#13895) * Fix up Eufy handling of colour lights The Eufy colour lights have separate colour and temperature modes, and give much less light output when in colour mode. Brightness is also handled in a slightly confusing way, which means that state must be maintained in order to avoid switching the light between modes by accident. Add some additional handling for that. * Bump the lakeside version This version has important bugfixes for colour bulbs. * Hound fixes --- homeassistant/components/eufy.py | 2 +- homeassistant/components/light/eufy.py | 16 +++++++++++++--- requirements_all.txt | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/eufy.py b/homeassistant/components/eufy.py index 53584be9fdc..733aa0adbfe 100644 --- a/homeassistant/components/eufy.py +++ b/homeassistant/components/eufy.py @@ -15,7 +15,7 @@ from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['lakeside==0.4'] +REQUIREMENTS = ['lakeside==0.5'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/light/eufy.py b/homeassistant/components/light/eufy.py index fa6550d2682..a66e219c1a8 100644 --- a/homeassistant/components/light/eufy.py +++ b/homeassistant/components/light/eufy.py @@ -48,12 +48,14 @@ class EufyLight(Light): self._code = device['code'] self._type = device['type'] self._bulb = lakeside.bulb(self._address, self._code, self._type) + self._colormode = False if self._type == "T1011": self._features = SUPPORT_BRIGHTNESS elif self._type == "T1012": self._features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP elif self._type == "T1013": - self._features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR + self._features = SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | \ + SUPPORT_COLOR self._bulb.connect() def update(self): @@ -62,9 +64,10 @@ class EufyLight(Light): self._brightness = self._bulb.brightness self._temp = self._bulb.temperature if self._bulb.colors: - self._hs = color_util.color_RGB_to_hsv(*self._bulb.colors) + self._colormode = True + self._hs = color_util.color_RGB_to_hs(*self._bulb.colors) else: - self._hs = None + self._colormode = False self._state = self._bulb.power @property @@ -108,6 +111,8 @@ class EufyLight(Light): @property def hs_color(self): """Return the color of this light.""" + if not self._colormode: + return None return self._hs @property @@ -128,6 +133,7 @@ class EufyLight(Light): brightness = max(1, self._brightness) if colortemp is not None: + self._colormode = False temp_in_k = mired_to_kelvin(colortemp) relative_temp = temp_in_k - EUFY_MIN_KELVIN temp = int(relative_temp * 100 / @@ -138,6 +144,10 @@ class EufyLight(Light): if hs is not None: rgb = color_util.color_hsv_to_RGB( hs[0], hs[1], brightness / 255 * 100) + self._colormode = True + elif self._colormode: + rgb = color_util.color_hsv_to_RGB( + self._hs[0], self._hs[1], brightness / 255 * 100) else: rgb = None diff --git a/requirements_all.txt b/requirements_all.txt index d5036a795fe..b4056f61cd0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -458,7 +458,7 @@ keyring==12.0.0 keyrings.alt==3.0 # homeassistant.components.eufy -lakeside==0.4 +lakeside==0.5 # homeassistant.components.device_tracker.owntracks # homeassistant.components.device_tracker.owntracks_http