Commit 8bb3e97
fix: don't slow EMA smoother across zero-crossings for high alpha (#373)
The sign-flip "catchup" branch in SmoothedPowermeter was meant to react
faster when raw power crosses zero by boosting the effective alpha to
`alpha * 4`, capped at 0.5. But `min(0.5, alpha * 4)` is only a boost
while `alpha < 0.125`; for any larger configured alpha it just clamps to
0.5, and for alpha > 0.5 it actively reduces the step.
Users running near self-consumption with a high `SMOOTH_TARGET_ALPHA`
(e.g. 1.0 for instant tracking) therefore saw randomly halved deltas
whenever the raw reading happened to straddle zero, often dragging the
smoothed value back into the deadband and snapping it to 0.
Raise the catchup alpha to at least the configured alpha so the branch
can only ever speed the smoother up, never slow it down.
Refs #371
Co-authored-by: Claude <noreply@anthropic.com>1 parent de053d3 commit 8bb3e97
3 files changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
89 | 106 | | |
90 | 107 | | |
91 | 108 | | |
| |||
0 commit comments