Report update_percentage in smlight update entity (#129383)

This commit is contained in:
Erik Montnemery 2024-10-29 17:50:43 +01:00 committed by GitHub
parent e34fab0045
commit 3a59a862d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,9 +153,8 @@ class SmUpdateEntity(SmEntity, UpdateEntity):
"""Update install progress on event."""
progress = int(progress.data)
if progress > 1:
self._attr_in_progress = progress
self.async_write_ha_state()
self._attr_update_percentage = progress
self.async_write_ha_state()
def _update_done(self) -> None:
"""Handle cleanup for update done."""
@ -166,6 +165,10 @@ class SmUpdateEntity(SmEntity, UpdateEntity):
remove_cb()
self._unload.clear()
self._attr_in_progress = False
self._attr_update_percentage = None
self.async_write_ha_state()
@callback
def _update_finished(self, event: MessageEvent) -> None:
"""Handle event for update finished."""
@ -186,6 +189,7 @@ class SmUpdateEntity(SmEntity, UpdateEntity):
if not self.coordinator.in_progress and self._firmware:
self.coordinator.in_progress = True
self._attr_in_progress = True
self._attr_update_percentage = None
self.register_callbacks()
await self.coordinator.client.fw_update(self._firmware)