1
mirror of https://github.com/home-assistant/core synced 2024-07-24 16:42:06 +02:00

Fix yeelight brightness in music mode (#45358)

This commit is contained in:
Xiaonan Shen 2021-01-21 15:54:24 +08:00 committed by GitHub
parent e97448a201
commit daa9449f18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):