Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2021.4.4 #49139

Merged
merged 17 commits into from
Apr 13, 2021
Merged

2021.4.4 #49139

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Shelly brightness offset (#49007)
  • Loading branch information
thecode authored and balloob committed Apr 13, 2021
commit 0bb7592fab3feddb5290b4459f58d2aa66c450aa
17 changes: 9 additions & 8 deletions homeassistant/components/shelly/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ def brightness(self) -> int:
"""Brightness of light."""
if self.mode == "color":
if self.control_result:
brightness = self.control_result["gain"]
brightness_pct = self.control_result["gain"]
else:
brightness = self.block.gain
brightness_pct = self.block.gain
else:
if self.control_result:
brightness = self.control_result["brightness"]
brightness_pct = self.control_result["brightness"]
else:
brightness = self.block.brightness
return int(brightness / 100 * 255)
brightness_pct = self.block.brightness

return round(255 * brightness_pct / 100)

@property
def white_value(self) -> int:
Expand Down Expand Up @@ -188,11 +189,11 @@ async def async_turn_on(self, **kwargs) -> None:
set_mode = None
params = {"turn": "on"}
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"):
params["gain"] = tmp_brightness
params["gain"] = brightness_pct
if hasattr(self.block, "brightness"):
params["brightness"] = tmp_brightness
params["brightness"] = brightness_pct
if ATTR_COLOR_TEMP in kwargs:
color_temp = color_temperature_mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
color_temp = min(self._max_kelvin, max(self._min_kelvin, color_temp))
Expand Down