Skip to content

Commit 059b161

Browse files
authored
Use actual latest version of OS in os version check (#6067)
1 parent f11eb6b commit 059b161

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

supervisor/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
ATTR_HASSIO_API = "hassio_api"
198198
ATTR_HASSIO_ROLE = "hassio_role"
199199
ATTR_HASSOS = "hassos"
200+
ATTR_HASSOS_UNRESTRICTED = "hassos_unrestricted"
200201
ATTR_HEALTHY = "healthy"
201202
ATTR_HEARTBEAT_LED = "heartbeat_led"
202203
ATTR_HOMEASSISTANT = "homeassistant"

supervisor/os/manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ def latest_version(self) -> AwesomeVersion | None:
110110
"""Return version of HassOS."""
111111
return self.sys_updater.version_hassos
112112

113+
@property
114+
def latest_version_unrestricted(self) -> AwesomeVersion | None:
115+
"""Return current latest version of HassOS for board ignoring upgrade restrictions."""
116+
return self.sys_updater.version_hassos_unrestricted
117+
113118
@property
114119
def need_update(self) -> bool:
115120
"""Return true if a HassOS update is available."""

supervisor/resolution/evaluations/os_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async def evaluate(self) -> bool:
3838
if (
3939
not self.sys_os.available
4040
or not (current := self.sys_os.version)
41-
or not (latest := self.sys_os.latest_version)
41+
or not (latest := self.sys_os.latest_version_unrestricted)
4242
or not latest.major
4343
):
4444
return False

supervisor/updater.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ATTR_CLI,
1919
ATTR_DNS,
2020
ATTR_HASSOS,
21+
ATTR_HASSOS_UNRESTRICTED,
2122
ATTR_HOMEASSISTANT,
2223
ATTR_IMAGE,
2324
ATTR_MULTICAST,
@@ -84,6 +85,11 @@ def version_hassos(self) -> AwesomeVersion | None:
8485
"""Return latest version of HassOS."""
8586
return self._data.get(ATTR_HASSOS)
8687

88+
@property
89+
def version_hassos_unrestricted(self) -> AwesomeVersion | None:
90+
"""Return latest version of HassOS ignoring upgrade restrictions."""
91+
return self._data.get(ATTR_HASSOS_UNRESTRICTED)
92+
8793
@property
8894
def version_cli(self) -> AwesomeVersion | None:
8995
"""Return latest version of CLI."""
@@ -275,6 +281,7 @@ async def fetch_data(self):
275281
if self.sys_os.board:
276282
self._data[ATTR_OTA] = data["ota"]
277283
if version := data["hassos"].get(self.sys_os.board):
284+
self._data[ATTR_HASSOS_UNRESTRICTED] = version
278285
events.append("os")
279286
upgrade_map = data.get("hassos-upgrade", {})
280287
if last_in_major := upgrade_map.get(str(self.sys_os.version.major)):

supervisor/validate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ATTR_ENABLE_IPV6,
2424
ATTR_FORCE_SECURITY,
2525
ATTR_HASSOS,
26+
ATTR_HASSOS_UNRESTRICTED,
2627
ATTR_HOMEASSISTANT,
2728
ATTR_ID,
2829
ATTR_IMAGE,
@@ -126,6 +127,7 @@ def validate_repository(repository: str) -> str:
126127
vol.Optional(ATTR_HOMEASSISTANT): version_tag,
127128
vol.Optional(ATTR_SUPERVISOR): version_tag,
128129
vol.Optional(ATTR_HASSOS): version_tag,
130+
vol.Optional(ATTR_HASSOS_UNRESTRICTED): version_tag,
129131
vol.Optional(ATTR_CLI): version_tag,
130132
vol.Optional(ATTR_DNS): version_tag,
131133
vol.Optional(ATTR_AUDIO): version_tag,

tests/resolution/evaluation/test_evaluate_os_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def test_os_version_evaluation(
4949
),
5050
patch.object(
5151
OSManager,
52-
"latest_version",
52+
"latest_version_unrestricted",
5353
new=PropertyMock(return_value=latest and AwesomeVersion(latest)),
5454
),
5555
):

0 commit comments

Comments
 (0)