diff --git a/custom_components/hilo/sensor.py b/custom_components/hilo/sensor.py index 2a71e98..ed1ac9e 100755 --- a/custom_components/hilo/sensor.py +++ b/custom_components/hilo/sensor.py @@ -24,6 +24,7 @@ UnitOfPower, UnitOfSoundPressure, UnitOfTemperature, + __short_version__ as current_version, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceInfo @@ -32,6 +33,7 @@ from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.util import Throttle, slugify import homeassistant.util.dt as dt_util +from packaging.version import Version from pyhilo.const import UNMONITORED_DEVICES from pyhilo.device import HiloDevice from pyhilo.event import Event @@ -293,17 +295,29 @@ def __init__(self, hilo, device): identifiers={(DOMAIN, self._device.identifier)}, ) - super().__init__( - integration_method=METHOD_LEFT, - max_sub_interval=timedelta(seconds=MAX_SUB_INTERVAL), - name=self._attr_name, - round_digits=2, - source_entity=self._source, - unique_id=self._attr_unique_id, - unit_prefix="k", - unit_time="h", - device_info=self._device_info, - ) + if Version(current_version) >= Version("2024.7"): + super().__init__( + integration_method=METHOD_LEFT, + max_sub_interval=timedelta(seconds=MAX_SUB_INTERVAL), + name=self._attr_name, + round_digits=2, + source_entity=self._source, + unique_id=self._attr_unique_id, + unit_prefix="k", + unit_time="h", + device_info=self._device_info, + ) + else: + super().__init__( + integration_method=METHOD_LEFT, + name=self._attr_name, + round_digits=2, + source_entity=self._source, + unique_id=self._attr_unique_id, + unit_prefix="k", + unit_time="h", + device_info=self._device_info, + ) self._unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR self._suggested_display_precision = 2