mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Fix firmware update failure (#103277)
This commit is contained in:
parent
89a9e6c6e8
commit
ac1dc4eeea
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import asdict, dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class ZWaveNodeFirmwareUpdateExtraStoredData(ExtraStoredData):
|
|||||||
def as_dict(self) -> dict[str, Any]:
|
def as_dict(self) -> dict[str, Any]:
|
||||||
"""Return a dict representation of the extra data."""
|
"""Return a dict representation of the extra data."""
|
||||||
return {
|
return {
|
||||||
ATTR_LATEST_VERSION_FIRMWARE: asdict(self.latest_version_firmware)
|
ATTR_LATEST_VERSION_FIRMWARE: self.latest_version_firmware.to_dict()
|
||||||
if self.latest_version_firmware
|
if self.latest_version_firmware
|
||||||
else None
|
else None
|
||||||
}
|
}
|
||||||
@ -339,19 +339,25 @@ class ZWaveNodeFirmwareUpdate(UpdateEntity):
|
|||||||
and (latest_version := state.attributes.get(ATTR_LATEST_VERSION))
|
and (latest_version := state.attributes.get(ATTR_LATEST_VERSION))
|
||||||
is not None
|
is not None
|
||||||
and (extra_data := await self.async_get_last_extra_data())
|
and (extra_data := await self.async_get_last_extra_data())
|
||||||
):
|
and (
|
||||||
self._attr_latest_version = latest_version
|
latest_version_firmware := ZWaveNodeFirmwareUpdateExtraStoredData.from_dict(
|
||||||
self._latest_version_firmware = (
|
|
||||||
ZWaveNodeFirmwareUpdateExtraStoredData.from_dict(
|
|
||||||
extra_data.as_dict()
|
extra_data.as_dict()
|
||||||
).latest_version_firmware
|
).latest_version_firmware
|
||||||
)
|
)
|
||||||
# If we have no state or latest version to restore, we can set the latest
|
):
|
||||||
|
self._attr_latest_version = latest_version
|
||||||
|
self._latest_version_firmware = latest_version_firmware
|
||||||
|
# If we have no state or latest version to restore, or the latest version is
|
||||||
|
# the same as the installed version, we can set the latest
|
||||||
# version to installed so that the entity starts as off. If we have partial
|
# version to installed so that the entity starts as off. If we have partial
|
||||||
# restore data due to an upgrade to an HA version where this feature is released
|
# restore data due to an upgrade to an HA version where this feature is released
|
||||||
# from one that is not the entity will start in an unknown state until we can
|
# from one that is not the entity will start in an unknown state until we can
|
||||||
# correct on next update
|
# correct on next update
|
||||||
elif not state or not latest_version:
|
elif (
|
||||||
|
not state
|
||||||
|
or not latest_version
|
||||||
|
or latest_version == self._attr_installed_version
|
||||||
|
):
|
||||||
self._attr_latest_version = self._attr_installed_version
|
self._attr_latest_version = self._attr_installed_version
|
||||||
|
|
||||||
# Spread updates out in 5 minute increments to avoid flooding the network
|
# Spread updates out in 5 minute increments to avoid flooding the network
|
||||||
|
Loading…
x
Reference in New Issue
Block a user