mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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
This commit is contained in:
parent
2cf3057ff1
commit
1a9420dda0
@ -327,13 +327,15 @@ class UpdateEntity(RestoreEntity):
|
|||||||
|
|
||||||
if latest_version == self.__skipped_version:
|
if latest_version == self.__skipped_version:
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
|
if latest_version == installed_version:
|
||||||
|
return STATE_OFF
|
||||||
|
|
||||||
try:
|
try:
|
||||||
newer = AwesomeVersion(latest_version) > installed_version
|
newer = AwesomeVersion(latest_version) > installed_version
|
||||||
return STATE_ON if newer else STATE_OFF
|
return STATE_ON if newer else STATE_OFF
|
||||||
except AwesomeVersionCompareException:
|
except AwesomeVersionCompareException:
|
||||||
# Can't compare versions, fallback to exact match
|
# Can't compare versions, already tried exact match
|
||||||
return STATE_OFF if latest_version == installed_version else STATE_ON
|
return STATE_ON
|
||||||
|
|
||||||
@final
|
@final
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user