Restore latest version of ZHA Update entity

Required for https://github.com/zigpy/zha/pull/460
pull/146400/head
abmantis 2025-06-09 18:01:57 +01:00
parent 0cce4d1b81
commit 0040e9e5af
1 changed files with 9 additions and 1 deletions

View File

@ -10,13 +10,14 @@ from zha.exceptions import ZHAException
from zigpy.application import ControllerApplication
from homeassistant.components.update import (
ATTR_LATEST_VERSION,
UpdateDeviceClass,
UpdateEntity,
UpdateEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, State, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
@ -195,3 +196,10 @@ class ZHAFirmwareUpdateEntity(
"""Update the entity."""
await CoordinatorEntity.async_update(self)
await super().async_update()
@callback
def restore_external_state_attributes(self, state: State) -> None:
"""Restore entity state."""
self.entity_data.entity.restore_external_state_attributes(
latest_version=state.attributes.get(ATTR_LATEST_VERSION),
)