Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix firmware update failure #103277

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions homeassistant/components/zwave_js/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
from collections import Counter
from collections.abc import Callable
from dataclasses import asdict, dataclass
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Any, Final

Expand Down Expand Up @@ -54,7 +54,7 @@ class ZWaveNodeFirmwareUpdateExtraStoredData(ExtraStoredData):
def as_dict(self) -> dict[str, Any]:
"""Return a dict representation of the extra data."""
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
else None
}
Expand Down Expand Up @@ -339,19 +339,25 @@ async def async_added_to_hass(self) -> None:
and (latest_version := state.attributes.get(ATTR_LATEST_VERSION))
is not None
and (extra_data := await self.async_get_last_extra_data())
):
self._attr_latest_version = latest_version
self._latest_version_firmware = (
ZWaveNodeFirmwareUpdateExtraStoredData.from_dict(
and (
latest_version_firmware := ZWaveNodeFirmwareUpdateExtraStoredData.from_dict(
extra_data.as_dict()
).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
# 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
# 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

# Spread updates out in 5 minute increments to avoid flooding the network
Expand Down
Loading