Skip to content

Commit

Permalink
Fix set brightness for Netatmo lights (#126075)
Browse files Browse the repository at this point in the history
* fix set brightness for Netatmo lights

* round returns int by default

* Update homeassistant/components/netatmo/light.py

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
  • Loading branch information
cgtobi and joostlek authored Sep 17, 2024
1 parent 2ec0d8e commit 0168894
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/netatmo/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ def __init__(self, netatmo_device: NetatmoDevice) -> None:
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn light on."""
if ATTR_BRIGHTNESS in kwargs:
await self.device.async_set_brightness(kwargs[ATTR_BRIGHTNESS])
await self.device.async_set_brightness(
round(kwargs[ATTR_BRIGHTNESS] / 2.55)
)

else:
await self.device.async_on()
Expand All @@ -194,6 +196,6 @@ def async_update_callback(self) -> None:

if (brightness := self.device.brightness) is not None:
# Netatmo uses a range of [0, 100] to control brightness
self._attr_brightness = round((brightness / 100) * 255)
self._attr_brightness = round(brightness * 2.55)
else:
self._attr_brightness = None

0 comments on commit 0168894

Please sign in to comment.