From 21575938ef4316beee4276a8138a2564386362a4 Mon Sep 17 00:00:00 2001 From: Magnus Brange Date: Thu, 2 May 2019 12:53:32 +0200 Subject: [PATCH] Prevent turning on tellduslive lights with 0 brightness (#23135) * Prevent turning on tellduslive lights with 0 brightness It was possible for the light compontent to get in a state where the last_brightness was set to zero, and when turning on (by calling turn_on) it would call the TellStick with 0 dim level, ergo not turning on the light. With this, it will fall back on a 75% dim level if the level is set to zero. * Wrap long log line over two lines And using a more proper way of formatting the message * Fallback to 100% instead of 75% --- homeassistant/components/tellduslive/light.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/components/tellduslive/light.py b/homeassistant/components/tellduslive/light.py index abbfd8ac92e..9233924ef1b 100644 --- a/homeassistant/components/tellduslive/light.py +++ b/homeassistant/components/tellduslive/light.py @@ -67,6 +67,11 @@ class TelldusLiveLight(TelldusLiveEntity, Light): def turn_on(self, **kwargs): """Turn the light on.""" brightness = kwargs.get(ATTR_BRIGHTNESS, self._last_brightness) + if brightness == 0: + fallback_brightness = 100 + _LOGGER.info("Setting brightness to %d%%, because it was 0", + fallback_brightness) + brightness = int(fallback_brightness*255/100) self.device.dim(level=brightness) self.changed()