From daa9449f18914f51b5a4ce56cdfd630b4628fd2a Mon Sep 17 00:00:00 2001 From: Xiaonan Shen <s@sxn.dev> Date: Thu, 21 Jan 2021 15:54:24 +0800 Subject: [PATCH] Fix yeelight brightness in music mode (#45358) --- homeassistant/components/yeelight/light.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index c1d4f14c813..c256cfb23e0 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -426,7 +426,6 @@ class YeelightGenericLight(YeelightEntity, LightEntity): self.config = device.config - self._brightness = None self._color_temp = None self._hs = None self._effect = None @@ -487,10 +486,14 @@ class YeelightGenericLight(YeelightEntity, LightEntity): @property def brightness(self) -> int: """Return the brightness of this light between 1..255.""" - temp = self._get_property(self._brightness_property) - if temp: - self._brightness = temp - return round(255 * (int(self._brightness) / 100)) + # Always use "bright" as property name in music mode + # Since music mode states are only caches in upstream library + # and the cache key is always "bright" for brightness + brightness_property = ( + "bright" if self._bulb.music_mode else self._brightness_property + ) + brightness = self._get_property(brightness_property) + return round(255 * (int(brightness) / 100)) @property def min_mireds(self):