Skip to content

Commit

Permalink
Filter, config
Browse files Browse the repository at this point in the history
Based on deleted branch by Daniel Hjelseth Høyer <[email protected]>
  • Loading branch information
dbrand666 committed Dec 4, 2024
1 parent dc9abc9 commit 9684e1a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/filter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
CONF_FILTER_PRECISION = "precision"
CONF_FILTER_RADIUS = "radius"
CONF_FILTER_TIME_CONSTANT = "time_constant"
CONF_FILTER_UPDATE_BY_TIME = "update_by_time"
CONF_FILTER_LOWER_BOUND = "lower_bound"
CONF_FILTER_UPPER_BOUND = "upper_bound"
CONF_TIME_SMA_TYPE = "type"
Expand All @@ -86,7 +87,7 @@
NAME_TEMPLATE = "{} filter"
ICON = "mdi:chart-line-variant"

SCAN_INTERVAL = timedelta(minutes=10)
SCAN_INTERVAL = timedelta(minutes=3)

FILTER_SCHEMA = vol.Schema({vol.Optional(CONF_FILTER_PRECISION): vol.Coerce(int)})

Expand Down Expand Up @@ -131,6 +132,7 @@
vol.Required(CONF_FILTER_WINDOW_SIZE): vol.All(
cv.time_period, cv.positive_timedelta
),
vol.Optional(CONF_FILTER_UPDATE_BY_TIME, default=False): cv.boolean,
}
)

Expand Down Expand Up @@ -227,7 +229,7 @@ def __init__(

self._attr_should_poll = False
for filt in filters:
if isinstance(filt, TimeSMAFilter):
if getattr(filt, "update_by_time", False):
self._attr_should_poll = True
break

Expand Down Expand Up @@ -661,6 +663,7 @@ def __init__(
entity: str,
type: str, # pylint: disable=redefined-builtin
precision: int = DEFAULT_PRECISION,
update_by_time: bool = False,
) -> None:
"""Initialize Filter.
Expand All @@ -670,6 +673,7 @@ def __init__(
FILTER_NAME_TIME_SMA, window_size, precision=precision, entity=entity
)
self._time_window = window_size
self.update_by_time = update_by_time
self.last_leak: FilterState | None = None
self.queue = deque[FilterState]()

Expand Down

0 comments on commit 9684e1a

Please sign in to comment.