From a71111b3788bc8818db9b104f205431fe2ec452c Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 16 Feb 2024 15:40:54 +0100 Subject: [PATCH] Fix autoupdate time compare (#4897) * Fix autoupdate time compare Make sure both timestamps are UTC, otherwise Python complains with: TypeError: can't compare offset-naive and offset-aware datetimes * Use correect attribute --------- Co-authored-by: Pascal Vizeli --- supervisor/addons/addon.py | 4 +++- supervisor/addons/model.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/supervisor/addons/addon.py b/supervisor/addons/addon.py index 1d9d01cee90..20660678254 100644 --- a/supervisor/addons/addon.py +++ b/supervisor/addons/addon.py @@ -22,6 +22,8 @@ import voluptuous as vol from voluptuous.humanize import humanize_error +from supervisor.utils.dt import utc_from_timestamp + from ..bus import EventListener from ..const import ( ATTR_ACCESS_TOKEN, @@ -349,7 +351,7 @@ def latest_version(self) -> str: @property def latest_version_timestamp(self) -> datetime: """Return when latest version was first seen.""" - return datetime.fromtimestamp(self.data_store[ATTR_VERSION_TIMESTAMP]) + return utc_from_timestamp(self.data_store[ATTR_VERSION_TIMESTAMP]) @property def protected(self) -> bool: diff --git a/supervisor/addons/model.py b/supervisor/addons/model.py index fb04729bd88..49aa34df878 100644 --- a/supervisor/addons/model.py +++ b/supervisor/addons/model.py @@ -10,6 +10,8 @@ from awesomeversion import AwesomeVersion, AwesomeVersionException +from supervisor.utils.dt import utc_from_timestamp + from ..const import ( ATTR_ADVANCED, ATTR_APPARMOR, @@ -227,7 +229,7 @@ def latest_version(self) -> AwesomeVersion: @property def latest_version_timestamp(self) -> datetime: """Return when latest version was first seen.""" - return datetime.fromtimestamp(self.data[ATTR_VERSION_TIMESTAMP]) + return utc_from_timestamp(self.data[ATTR_VERSION_TIMESTAMP]) @property def version(self) -> AwesomeVersion: