Skip to content

Commit

Permalink
Change firmware endpoint and handle non-SemVer firware (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 authored Nov 25, 2024
1 parent 8e34e9f commit 299f508
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions custom_components/opnsense/pyopnsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,22 @@ async def _exec_php(self, script) -> Mapping[str, Any]:
@_log_errors
async def get_host_firmware_version(self) -> None | str:
firmware_info: Mapping[str, Any] | list = await self._get(
"/api/core/firmware/info"
"/api/core/firmware/status"
)
if not isinstance(firmware_info, Mapping):
return None
firmware: str | None = firmware_info.get("product_version", None)
_LOGGER.debug(f"[get_host_firmware_version] firmware: {firmware}")
firmware: str | None = firmware_info.get("product", {}).get("product_version")
if not firmware or not awesomeversion.AwesomeVersion(firmware).valid:
old = firmware
firmware: str | None = firmware_info.get("product", {}).get(
"product_series", old
)
if firmware != old:
_LOGGER.debug(
f"[get_host_firmware_version] firmware: {old} not valid SemVer, using {firmware}"
)
else:
_LOGGER.debug(f"[get_host_firmware_version] firmware: {firmware}")
self._firmware_version = firmware
return firmware

Expand Down

0 comments on commit 299f508

Please sign in to comment.