bundles/homeassistant: fix version check

This commit is contained in:
Franzi 2024-10-27 17:37:14 +01:00
parent af78e959ae
commit 4f0ced4d9a
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -2,7 +2,7 @@
from sys import exit from sys import exit
from packaging import version from packaging.version import parse
from requests import get from requests import get
API_TOKEN = "${token}" API_TOKEN = "${token}"
@ -11,7 +11,7 @@ DOMAIN = "${domain}"
try: try:
r = get("https://version.home-assistant.io/stable.json") r = get("https://version.home-assistant.io/stable.json")
r.raise_for_status() r.raise_for_status()
stable_version = r.json()["homeassistant"]["generic-x86-64"] stable_version = parse(r.json()["homeassistant"]["generic-x86-64"])
except Exception as e: except Exception as e:
print(f"Could not get stable version information from home-assistant.io: {e!r}") print(f"Could not get stable version information from home-assistant.io: {e!r}")
exit(3) exit(3)
@ -22,7 +22,7 @@ try:
headers={"Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json"}, headers={"Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json"},
) )
r.raise_for_status() r.raise_for_status()
running_version = r.json()["version"] running_version = parse(r.json()["version"])
except Exception as e: except Exception as e:
print(f"Could not get running version information from homeassistant: {e!r}") print(f"Could not get running version information from homeassistant: {e!r}")
exit(3) exit(3)