Use version_pending to finalize HAOS update state (#177155)

This commit is contained in:
Mike Degatano
2026-07-24 12:21:48 +08:00
committed by GitHub
parent de37e6be45
commit d80c0e2cc5
2 changed files with 9 additions and 5 deletions
+3 -1
View File
@@ -257,7 +257,9 @@ class SupervisorOSUpdateEntity(HassioOSEntity, UpdateEntity):
def installed_version(self) -> str | None:
"""Return the installed version."""
assert self.coordinator.data.os is not None
return self.coordinator.data.os.version
return (
self.coordinator.data.os.version_pending or self.coordinator.data.os.version
)
@property
@override
+6 -4
View File
@@ -71,6 +71,7 @@ def mock_all(
os_info.return_value,
version="1.0.0dev2221",
version_latest="1.0.0dev2222",
version_pending=None,
update_available=True,
)
supervisor_info.return_value = replace(
@@ -540,10 +541,11 @@ async def test_update_os(
await hass.async_block_till_done()
async def mock_os_update(*args: Any) -> None:
"""Simulate Supervisor reporting the new version after the update."""
"""Simulate Supervisor keeping version stable while pending version updates."""
os_info.return_value = replace(
os_info.return_value,
version="1.0.0dev2222",
version="1.0.0dev2221",
version_pending="1.0.0dev2222",
update_available=False,
)
@@ -560,8 +562,8 @@ async def test_update_os(
mock_create_backup.assert_not_called()
supervisor_client.os.update.assert_called_once_with(OSUpdate(version=None))
# The coordinator is refreshed after install so the new version
# shows up immediately
# The coordinator refresh reflects the new pending version while
# the base version remains unchanged.
state = hass.states.get("update.home_assistant_operating_system_update")
assert state is not None
assert state.state == "off"