mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Fix Shelly brightness offset (#49007)
This commit is contained in:
parent
ff8e4fb77f
commit
5c71ba578d
@ -118,15 +118,16 @@ class ShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
"""Brightness of light."""
|
"""Brightness of light."""
|
||||||
if self.mode == "color":
|
if self.mode == "color":
|
||||||
if self.control_result:
|
if self.control_result:
|
||||||
brightness = self.control_result["gain"]
|
brightness_pct = self.control_result["gain"]
|
||||||
else:
|
else:
|
||||||
brightness = self.block.gain
|
brightness_pct = self.block.gain
|
||||||
else:
|
else:
|
||||||
if self.control_result:
|
if self.control_result:
|
||||||
brightness = self.control_result["brightness"]
|
brightness_pct = self.control_result["brightness"]
|
||||||
else:
|
else:
|
||||||
brightness = self.block.brightness
|
brightness_pct = self.block.brightness
|
||||||
return int(brightness / 100 * 255)
|
|
||||||
|
return round(255 * brightness_pct / 100)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def white_value(self) -> int:
|
def white_value(self) -> int:
|
||||||
@ -188,11 +189,11 @@ class ShellyLight(ShellyBlockEntity, LightEntity):
|
|||||||
set_mode = None
|
set_mode = None
|
||||||
params = {"turn": "on"}
|
params = {"turn": "on"}
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
tmp_brightness = int(kwargs[ATTR_BRIGHTNESS] / 255 * 100)
|
brightness_pct = int(100 * (kwargs[ATTR_BRIGHTNESS] + 1) / 255)
|
||||||
if hasattr(self.block, "gain"):
|
if hasattr(self.block, "gain"):
|
||||||
params["gain"] = tmp_brightness
|
params["gain"] = brightness_pct
|
||||||
if hasattr(self.block, "brightness"):
|
if hasattr(self.block, "brightness"):
|
||||||
params["brightness"] = tmp_brightness
|
params["brightness"] = brightness_pct
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
color_temp = color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
|
color_temp = color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
|
||||||
color_temp = min(self._max_kelvin, max(self._min_kelvin, color_temp))
|
color_temp = min(self._max_kelvin, max(self._min_kelvin, color_temp))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user