Skip to content

Commit

Permalink
Improve integral sensor behavior
Browse files Browse the repository at this point in the history
Using new max_sub_interval we can control how often integral are updated
in case the source sensor is constant.
  • Loading branch information
kamaradclimber committed Jul 5, 2024
1 parent 74a0220 commit 735bb62
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion custom_components/aquarea/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Optional
from dataclasses import dataclass
from collections.abc import Callable
from datetime import timedelta

from homeassistant.components import mqtt
from homeassistant.components.sensor import (
Expand Down Expand Up @@ -193,7 +194,8 @@ async def async_setup_entry(
unique_id=f"{sensor._attr_unique_id}_integration",
unit_prefix="k",
unit_time=UnitOfTime.HOURS,
max_sub_interval=None,
# update integral at least once every 5 minutes, even if source does not change
max_sub_interval=timedelta(minutes=5),
device_info=sensor.device_info,
))
async_add_entities(integration_sensors)
Expand Down

0 comments on commit 735bb62

Please sign in to comment.