From 7da1d757073c0dd49e7b6e17102b725388e5ac85 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Fri, 27 Apr 2018 13:39:07 -0700 Subject: [PATCH] Change Eufy brightness handling (#14111) Eufy device state isn't reported if the bulb is off, so avoid stamping on the previous values if the bulb isn't going to give us useful information. In addition, improve handling of bulb turn on if we aren't provided with a brightness - this should avoid the bulb tending to end up with a brightness of 1 after power cycling. --- homeassistant/components/light/eufy.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/light/eufy.py b/homeassistant/components/light/eufy.py index a66e219c1a8..6f0a8816eea 100644 --- a/homeassistant/components/light/eufy.py +++ b/homeassistant/components/light/eufy.py @@ -61,13 +61,14 @@ class EufyLight(Light): def update(self): """Synchronise state from the bulb.""" self._bulb.update() - self._brightness = self._bulb.brightness - self._temp = self._bulb.temperature - if self._bulb.colors: - self._colormode = True - self._hs = color_util.color_RGB_to_hs(*self._bulb.colors) - else: - self._colormode = False + if self._bulb.power: + self._brightness = self._bulb.brightness + self._temp = self._bulb.temperature + if self._bulb.colors: + self._colormode = True + self._hs = color_util.color_RGB_to_hs(*self._bulb.colors) + else: + self._colormode = False self._state = self._bulb.power @property @@ -130,7 +131,9 @@ class EufyLight(Light): if brightness is not None: brightness = int(brightness * 100 / 255) else: - brightness = max(1, self._brightness) + if self._brightness is None: + self._brightness = 100 + brightness = self._brightness if colortemp is not None: self._colormode = False