feat: implement ThrottledSensorMixin to reduce Home Assistant write amplification#62
Open
celestinjr wants to merge 2 commits intoCrewski:mainfrom
Open
feat: implement ThrottledSensorMixin to reduce Home Assistant write amplification#62celestinjr wants to merge 2 commits intoCrewski:mainfrom
celestinjr wants to merge 2 commits intoCrewski:mainfrom
Conversation
…nd==10 PumpOnSensor relied on command==10 to determine if a pump is running. This is incorrect for Regal Modbus pumps, which emit command=4 while actively running (e.g. rpm=3450, watts=1406, command=4), causing the running state sensor to incorrectly toggle off/on with each state update. Fix: for non-relay pumps, use rpm>0 or watts>0 as the running indicator. Relay-based pumps retain existing relay>0 logic. Aligns with the same fix applied in nodejs-poolController-dashPanel.
Implement intelligent throttling for high-frequency push-driven sensors across the integration (pump, temperature, filter sensors). Reduces HomeAssistant/InfluxDB writes while preserving responsiveness through configurable delta-based and binary throttling modes. Also fixes PumpSpeedSensor max_speed scalar bug.
Author
|
Depends on #61 . Please merge that fix first for cleaner history. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
High-frequency push-driven sensors (pump speed, power, temps, filter pressure)
cause write amplification in InfluxDB and high update churn in Home Assistant.
Solution
Implement a reusable
ThrottledSensorMixinthat intelligently throttles stateupdates with two modes:
changes immediate, identical values skipped (pump speed, power, temps)
values skipped (pump running state, filter on/off)
Throttle thresholds are configurable per-entity and defined in
const.py.Entities Throttled
Additional Fix
Also fixes: PumpSpeedSensor
max_speed/min_speedtuple bug (now returns scalar).Testing
Dependency
This PR is rebased on top of #61 (fix/pump-running-state-regal-modbus).
The running state fix is included in this branch. Recommend reviewing/merging
that fix first, then this enhancement.