Skip to content

Commit e279d63

Browse files
committed
Improve library version tracking
1 parent f559c91 commit e279d63

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

.github/workflows/update_victron_mqtt.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
# Compare against the vendored lib version by checking the wheel we'd download
4040
latest="${{ steps.get_release.outputs.latest_version }}"
4141
# Check if the lib/ directory already has this version by looking at a marker file
42-
if [ -f "custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version" ]; then
43-
current=$(cat custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version)
42+
if [ -f "custom_components/victron_mqtt/_vendor/__init__.py" ]; then
43+
current=$(python3 -c "import re; m = re.search(r'VICTRON_MQTT_VERSION\s*=\s*\"(.+?)\"', open('custom_components/victron_mqtt/_vendor/__init__.py').read()); print(m.group(1) if m else 'unknown')")
4444
else
4545
current="unknown"
4646
fi
@@ -75,8 +75,12 @@ jobs:
7575
rm -f custom_components/victron_mqtt/_vendor/victron_mqtt/py.typed
7676
rm -rf custom_components/victron_mqtt/_vendor/victron_mqtt/utils
7777
78-
# Write version marker
79-
echo "$latest" > custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version
78+
# Write version constant to _vendor/__init__.py
79+
cat > custom_components/victron_mqtt/_vendor/__init__.py << PYEOF
80+
"""Vendored third-party packages."""
81+
82+
VICTRON_MQTT_VERSION = "$latest"
83+
PYEOF
8084

8185
# Cleanup
8286
rm -rf /tmp/victron_wheel /tmp/victron_extracted

custom_components/victron_mqtt/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""The victron_mqtt integration."""
22

3-
import importlib.metadata
43
import logging
54

65
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
@@ -13,6 +12,7 @@
1312

1413
from .const import ATTR_DEVICE_ID, ATTR_METRIC_ID, ATTR_VALUE, CONF_SIMPLE_NAMING, DOMAIN, SERVICE_PUBLISH
1514
from .hub import Hub, VictronGxConfigEntry
15+
from ._vendor import VICTRON_MQTT_VERSION
1616

1717
_LOGGER = logging.getLogger(__name__)
1818
_VICTRON_MQTT_LOGGER = logging.getLogger("victron_mqtt")
@@ -68,14 +68,10 @@ async def handle_publish(call: ServiceCall) -> None:
6868
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
6969
"""Set up the integration."""
7070
version = getattr(hass.data.get("integrations", {}).get(DOMAIN), "version", "unknown")
71-
try:
72-
victron_mqtt_version = importlib.metadata.version("victron_mqtt")
73-
except importlib.metadata.PackageNotFoundError:
74-
victron_mqtt_version = "vendored"
7571
_LOGGER.info(
7672
"Setting up victron_mqtt integration. Version: %s. victron_mqtt package version: %s",
7773
version,
78-
victron_mqtt_version,
74+
VICTRON_MQTT_VERSION,
7975
)
8076

8177
return True
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Vendored third-party packages."""
2+
3+
VICTRON_MQTT_VERSION = "2026.5.7"

custom_components/victron_mqtt/_vendor/victron_mqtt/.vendored_version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)