Add configurable finish_time debounce to cut recorder churn further
Minute-rounding stopped identical values from re-logging, but finish_time still updates on nearly every poll because now() + remaining is a continuously-drifting value between the device's own remaining-time revisions, and washers/dryers/dishwashers commonly revise that estimate by a minute or two mid-cycle anyway -- both are real, small changes that individually don't matter but each cost a recorder/logbook entry. Add a per-device Options Flow setting (finish_time_debounce_minutes, default 3) and a SensorDesc(debounce=True) opt-in. LocalThingsSensor now caches the last value it actually reported and only adopts a new one once it differs by at least the configured threshold, a cycle starts (no prior cache), or a cycle ends (new value is None) -- 0 disables it entirely, restoring today's behavior. Also pass config_entry explicitly into DataUpdateCoordinator's super().__init__() -- self.config_entry previously relied on an undocumented ContextVar fallback that upstream has flagged as removed in HA 2026.8, which the new debounce lookup needed to not be built on top of.
This commit is contained in:
1 parent
fe9a1128ea
commit
d90562017f
9 files changed
+176
-11
No files matched your search
@@ -163,7 +163,7 @@ OPERATIONAL_STATE = Capability(
|
||||
# firmware leaves a stale remainingTime after a cycle ends, and
|
||||
# freezes it at '00:01:00' when progress reaches 'Finish'.
|
||||
SensorDesc(key='finish_time', device_class='timestamp',
|
||||
rep_fn=_finish_time),
|
||||
debounce=True, rep_fn=_finish_time),
|
||||
|
||||
SensorDesc(key='completion_minutes',
|
||||
icon='mdi:clock-outline', unit='min',
|
||||
|
||||
@@ -57,6 +57,11 @@ class SensorDesc(SamsungEntityDescription):
|
||||
unit: Optional[str] = None
|
||||
unit_fn: Optional[Callable[[dict], str]] = None # overrides `unit` from the live rep, when set
|
||||
options: Optional[tuple] = None # required by HA when device_class == 'enum'
|
||||
# Opt-in: gate this sensor's reported value behind the user-configurable
|
||||
# CONF_FINISH_TIME_DEBOUNCE_MINUTES threshold (see sensor.py). Only for
|
||||
# values that are expected to jitter around their "true" value between
|
||||
# device-side revisions -- not a general-purpose flag every sensor should set.
|
||||
debounce: bool = False
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
|
||||
Reference in new issue
Block a user