mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Report update_percentage in shelly update entity (#129382)
Co-authored-by: Shay Levy <levyshay1@gmail.com>
This commit is contained in:
parent
df16e6d022
commit
2d2f55a4df
@ -238,7 +238,8 @@ class RpcUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize update entity."""
|
"""Initialize update entity."""
|
||||||
super().__init__(coordinator, key, attribute, description)
|
super().__init__(coordinator, key, attribute, description)
|
||||||
self._ota_in_progress: bool | int = False
|
self._ota_in_progress = False
|
||||||
|
self._ota_progress_percentage: int | None = None
|
||||||
self._attr_release_url = get_release_url(
|
self._attr_release_url = get_release_url(
|
||||||
coordinator.device.gen, coordinator.model, description.beta
|
coordinator.device.gen, coordinator.model, description.beta
|
||||||
)
|
)
|
||||||
@ -256,11 +257,12 @@ class RpcUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
|
|||||||
if self.in_progress is not False:
|
if self.in_progress is not False:
|
||||||
event_type = event["event"]
|
event_type = event["event"]
|
||||||
if event_type == OTA_BEGIN:
|
if event_type == OTA_BEGIN:
|
||||||
self._ota_in_progress = 0
|
self._ota_progress_percentage = 0
|
||||||
elif event_type == OTA_PROGRESS:
|
elif event_type == OTA_PROGRESS:
|
||||||
self._ota_in_progress = event["progress_percent"]
|
self._ota_progress_percentage = event["progress_percent"]
|
||||||
elif event_type in (OTA_ERROR, OTA_SUCCESS):
|
elif event_type in (OTA_ERROR, OTA_SUCCESS):
|
||||||
self._ota_in_progress = False
|
self._ota_in_progress = False
|
||||||
|
self._ota_progress_percentage = None
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -278,10 +280,15 @@ class RpcUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
|
|||||||
return self.installed_version
|
return self.installed_version
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def in_progress(self) -> bool | int:
|
def in_progress(self) -> bool:
|
||||||
"""Update installation in progress."""
|
"""Update installation in progress."""
|
||||||
return self._ota_in_progress
|
return self._ota_in_progress
|
||||||
|
|
||||||
|
@property
|
||||||
|
def update_percentage(self) -> int | None:
|
||||||
|
"""Update installation progress."""
|
||||||
|
return self._ota_progress_percentage
|
||||||
|
|
||||||
async def async_install(
|
async def async_install(
|
||||||
self, version: str | None, backup: bool, **kwargs: Any
|
self, version: str | None, backup: bool, **kwargs: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -310,6 +317,7 @@ class RpcUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
|
|||||||
await self.coordinator.async_shutdown_device_and_start_reauth()
|
await self.coordinator.async_shutdown_device_and_start_reauth()
|
||||||
else:
|
else:
|
||||||
self._ota_in_progress = True
|
self._ota_in_progress = True
|
||||||
|
self._ota_progress_percentage = None
|
||||||
LOGGER.debug("OTA update call for %s successful", self.coordinator.name)
|
LOGGER.debug("OTA update call for %s successful", self.coordinator.name)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user