diff --git a/homeassistant/components/hassio/update.py b/homeassistant/components/hassio/update.py index afe62408ef55..07a4bf42b2ad 100644 --- a/homeassistant/components/hassio/update.py +++ b/homeassistant/components/hassio/update.py @@ -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 diff --git a/tests/components/hassio/test_update.py b/tests/components/hassio/test_update.py index 6dbd236771e4..de88658557cc 100644 --- a/tests/components/hassio/test_update.py +++ b/tests/components/hassio/test_update.py @@ -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"