Fix Netatmo light switching states by assuming state until next update (#106162)

This commit is contained in:
Tobias Sauerwein 2023-12-22 07:37:57 +01:00 committed by Franck Nijhof
parent 0beb47ac2c
commit 5ab41c40a6
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -186,11 +186,6 @@ class NetatmoLight(NetatmoBase, LightEntity):
] ]
) )
@property
def is_on(self) -> bool:
"""Return true if light is on."""
return self._dimmer.on is True
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn light on.""" """Turn light on."""
if ATTR_BRIGHTNESS in kwargs: if ATTR_BRIGHTNESS in kwargs:
@ -211,6 +206,8 @@ class NetatmoLight(NetatmoBase, LightEntity):
@callback @callback
def async_update_callback(self) -> None: def async_update_callback(self) -> None:
"""Update the entity's state.""" """Update the entity's state."""
self._attr_is_on = self._dimmer.on is True
if self._dimmer.brightness is not None: if self._dimmer.brightness is not None:
# Netatmo uses a range of [0, 100] to control brightness # Netatmo uses a range of [0, 100] to control brightness
self._attr_brightness = round((self._dimmer.brightness / 100) * 255) self._attr_brightness = round((self._dimmer.brightness / 100) * 255)