Skip to content

Commit

Permalink
Use GitHub for Firmware Changelog link
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 committed Jan 18, 2025
1 parent 7bf90fe commit 9200066
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions custom_components/opnsense/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def _handle_coordinator_update(self) -> None:
try:
product_version = dict_get(state, "firmware_update_info.product.product_version")
product_latest = dict_get(state, "firmware_update_info.product.product_latest")
product_series = dict_get(state, "firmware_update_info.product.product_series")
if product_version is None or product_latest is None:
self._attr_latest_version = None

Expand All @@ -128,9 +129,30 @@ def _handle_coordinator_update(self) -> None:
except (TypeError, KeyError, AttributeError):
self._attr_latest_version = None

self._attr_release_url = (
self.config_entry.data.get("url", None) + "/ui/core/firmware#changelog"
)
product_class: str | None = None
if product_series:
try:
series_minor: str | None = str(product_series).split(".")[1]
except IndexError:
series_minor = None
if series_minor in {"1", "7"}:
product_class = "community"
elif series_minor in {"4", "10"}:
product_class = "business"
# _LOGGER.debug(
# "[Update handle_coordinator_update] product_version: %s, product_latest: %s, product_series: %s, product_class: %s",
# product_version,
# product_latest,
# product_series,
# product_class,
# )

if product_series and product_latest and product_class:
self._attr_release_url = f"https://github.com/opnsense/changelog/blob/master/{product_class}/{product_series}/{product_latest}"
else:
self._attr_release_url = (
self.config_entry.data.get("url", None) + "/ui/core/firmware#changelog"
)

summary: str | None = None
try:
Expand Down

0 comments on commit 9200066

Please sign in to comment.