Skip to content

Commit

Permalink
Merge pull request #443 from dvd-dev/issue442
Browse files Browse the repository at this point in the history
Fix pour issue #442
  • Loading branch information
valleedelisle authored Jul 3, 2024
2 parents 968eca5 + d54af95 commit a26f416
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions custom_components/hilo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# Note ic-dev21: we'll stay at 300 until proper fix
EVENT_SCAN_INTERVAL_REDUCTION = 300
NOTIFICATION_SCAN_INTERVAL = 1800
MAX_SUB_INTERVAL = 120
MIN_SCAN_INTERVAL = 60
REWARD_SCAN_INTERVAL = 7200

Expand Down
2 changes: 1 addition & 1 deletion custom_components/hilo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/dvd-dev/hilo/issues",
"requirements": ["python-hilo>=2024.6.1"],
"version": "2024.6.2"
"version": "2024.7.1"
}
36 changes: 26 additions & 10 deletions custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
UnitOfPower,
UnitOfSoundPressure,
UnitOfTemperature,
__short_version__ as current_version,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceInfo
Expand All @@ -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
Expand All @@ -55,6 +57,7 @@
HILO_ENERGY_TOTAL,
HILO_SENSOR_CLASSES,
LOG,
MAX_SUB_INTERVAL,
NOTIFICATION_SCAN_INTERVAL,
REWARD_SCAN_INTERVAL,
TARIFF_LIST,
Expand Down Expand Up @@ -292,16 +295,29 @@ def __init__(self, hilo, device):
identifiers={(DOMAIN, self._device.identifier)},
)

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,
)
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

Expand Down

0 comments on commit a26f416

Please sign in to comment.