From 2d2873f75f7971c7bbffaedc799c5a0c1c027516 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 20 Apr 2026 18:44:34 +0000 Subject: [PATCH] feat(entity): expose integration version as sw_version in device info Read the version field from manifest.json at import time via a new INTEGRATION_VERSION constant in const.py. Pass it as sw_version to DeviceInfo in TibberPricesEntity so the current integration version is visible in the HA device registry. Impact: Device page in HA now shows the installed integration version under firmware/software version. --- custom_components/tibber_prices/const.py | 3 +++ custom_components/tibber_prices/entity.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/tibber_prices/const.py b/custom_components/tibber_prices/const.py index 9469c98..635f191 100644 --- a/custom_components/tibber_prices/const.py +++ b/custom_components/tibber_prices/const.py @@ -20,6 +20,9 @@ if TYPE_CHECKING: DOMAIN = "tibber_prices" LOGGER = logging.getLogger(__package__) +# Integration version from manifest.json (used for DeviceInfo sw_version) +INTEGRATION_VERSION: str = json.loads((Path(__file__).parent / "manifest.json").read_text(encoding="utf-8"))["version"] + # Data storage keys DATA_CHART_CONFIG = "chart_config" # Key for chart export config in hass.data DATA_CHART_METADATA_CONFIG = "chart_metadata_config" # Key for chart metadata config in hass.data diff --git a/custom_components/tibber_prices/entity.py b/custom_components/tibber_prices/entity.py index 9030325..b429da6 100644 --- a/custom_components/tibber_prices/entity.py +++ b/custom_components/tibber_prices/entity.py @@ -5,7 +5,7 @@ from __future__ import annotations from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import ATTRIBUTION, DOMAIN, get_home_type_translation, get_translation +from .const import ATTRIBUTION, DOMAIN, INTEGRATION_VERSION, get_home_type_translation, get_translation from .coordinator import TibberPricesDataUpdateCoordinator @@ -41,6 +41,7 @@ class TibberPricesEntity(CoordinatorEntity[TibberPricesDataUpdateCoordinator]): manufacturer="Tibber", model=translated_model, serial_number=home_id or None, + sw_version=INTEGRATION_VERSION, configuration_url="https://developer.tibber.com/explorer", )