Fix yolink dimmer Incorrect state update (#92986)

fix state update
pull/92999/head
Matrix 2023-05-12 22:15:04 +08:00 committed by GitHub
parent 4a50c3fbae
commit 7807df4426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -51,9 +51,9 @@ class YoLinkDimmerEntity(YoLinkEntity, LightEntity):
@callback
def update_entity_state(self, state: dict[str, Any]) -> None:
"""Update HA Entity State."""
if (dimmer_is_on := state.get("state")) is not None:
if (dimmer_state := state.get("state")) is not None:
# update _attr_is_on when device report it's state
self._attr_is_on = dimmer_is_on
self._attr_is_on = dimmer_state == "open"
if (brightness := state.get("brightness")) is not None:
self._attr_brightness = round(255 * brightness / 100)
self.async_write_ha_state()