From 1a9420dda0d7d98445366df57fda381e8d31bd62 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 5 Apr 2022 03:51:25 -1000 Subject: [PATCH] Try exact match first for update state (#69335) - Exact matches are much cheaper than creating an AwesomeVersion and calling the __gt__ method, and since most of the time the result is expected to be off, we want to optimize for this case --- homeassistant/components/update/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/update/__init__.py b/homeassistant/components/update/__init__.py index 90418dbf8b9..100b5dcc35e 100644 --- a/homeassistant/components/update/__init__.py +++ b/homeassistant/components/update/__init__.py @@ -327,13 +327,15 @@ class UpdateEntity(RestoreEntity): if latest_version == self.__skipped_version: return STATE_OFF + if latest_version == installed_version: + return STATE_OFF try: newer = AwesomeVersion(latest_version) > installed_version return STATE_ON if newer else STATE_OFF except AwesomeVersionCompareException: - # Can't compare versions, fallback to exact match - return STATE_OFF if latest_version == installed_version else STATE_ON + # Can't compare versions, already tried exact match + return STATE_ON @final @property