Skip to content

UserWarning: Can not use find_first_match without ensure_strategy #536

@DrBlokmeister

Description

@DrBlokmeister

For quite some time, I've been getting these warnings in my logs:

2026-03-30 07:27:08.151 WARNING (MainThread) [py.warnings] /config/custom_components/luxtronik/update.py:127: UserWarning: Can not use find_first_match without ensure_strategy, this is ignored and will start raising an exception in 2025. latest = AwesomeVersion( 
2026-03-30 07:27:08.151 WARNING (MainThread) [py.warnings] /config/custom_components/luxtronik/update.py:131: UserWarning: Can not use find_first_match without ensure_strategy, this is ignored and will start raising an exception in 2025. installed = AwesomeVersion(

Even after updating to the latest version, this issue still persists.

I think this is because update.py uses this in version_is_newer():

latest = AwesomeVersion(normalize(latest_version), find_first_match=True)
installed = AwesomeVersion(normalize(installed_version), find_first_match=True)

without using ensure_strategy.

I requested ChatGPT for a solution and it came up with this diff:

diff --git a/custom_components/luxtronik/update.py b/custom_components/luxtronik/update.py
index f06cfdbb..0689b86a 100644
--- a/custom_components/luxtronik/update.py
+++ b/custom_components/luxtronik/update.py
@@ -6,7 +6,7 @@ from __future__ import annotations
 import aiohttp
 import re
 
-from awesomeversion import AwesomeVersion
+from awesomeversion import AwesomeVersion, AwesomeVersionStrategy
 from datetime import datetime, timedelta, timezone
 from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
 from homeassistant.config_entries import ConfigEntry
@@ -121,18 +121,21 @@ class LuxtronikUpdateEntity(LuxtronikEntity, UpdateEntity):
         """Return True if latest_version is newer than installed_version."""
 
         def normalize(version: str) -> str:
-            # Remove any leading non-digit characters
-            return re.sub(r"^[^\d]+", "", version)
+            """Normalize Luxtronik firmware versions for comparison."""
+            version = re.sub(r"^[^\d]+", "", version)  # Strip leading V/B/etc.
+            version = version.split("-")[0]  # Ignore build suffix like -9086
+            return version
 
         latest = AwesomeVersion(
             normalize(latest_version),
             find_first_match=True,
+            ensure_strategy=[AwesomeVersionStrategy.SEMVER],
         )
         installed = AwesomeVersion(
             normalize(installed_version),
             find_first_match=True,
+            ensure_strategy=[AwesomeVersionStrategy.SEMVER],
         )
-
         return latest > installed
 
     @staticmethod

Implementing this solved the issue for me.

Maybe there is another solution as well, but I'm not knowledgeable enough to find one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions