Fix set brightness for Netatmo lights (#126075)

* 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>
This commit is contained in:
Tobias Sauerwein 2024-09-17 16:34:26 +02:00 committed by Franck Nijhof
parent c64222de4f
commit d924fc5967
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -173,7 +173,9 @@ class NetatmoLight(NetatmoModuleEntity, LightEntity):
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()
@ -194,6 +196,6 @@ class NetatmoLight(NetatmoModuleEntity, LightEntity):
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