Make Netatmo/Legrande/BTicino lights and switches optimistic (#81246)

* Make Netatmo lights optimistic

* Same for switches
This commit is contained in:
Tobias Sauerwein 2022-10-30 13:27:42 +01:00 committed by GitHub
parent 662aee17a6
commit df29a8388d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -193,17 +193,20 @@ class NetatmoLight(NetatmoBase, LightEntity):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn light on."""
_LOGGER.debug("Turn light '%s' on", self.name)
if ATTR_BRIGHTNESS in kwargs:
await self._dimmer.async_set_brightness(kwargs[ATTR_BRIGHTNESS])
else:
await self._dimmer.async_on()
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn light off."""
_LOGGER.debug("Turn light '%s' off", self.name)
await self._dimmer.async_off()
self._attr_is_on = False
self.async_write_ha_state()
@callback
def async_update_callback(self) -> None:

View File

@ -77,7 +77,11 @@ class NetatmoSwitch(NetatmoBase, SwitchEntity):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the zone on."""
await self._switch.async_on()
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the zone off."""
await self._switch.async_off()
self._attr_is_on = False
self.async_write_ha_state()