mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
refactor: convert flexibility_pct to ratio once at function entry
Co-authored-by: jpawlowski <75446+jpawlowski@users.noreply.github.com>
This commit is contained in:
parent
771afe7c0f
commit
62eacfb30b
1 changed files with 4 additions and 1 deletions
|
|
@ -181,6 +181,9 @@ def filter_price_outliers(
|
|||
flexibility_pct,
|
||||
)
|
||||
|
||||
# Convert percentage to ratio once for all comparisons (e.g., 15.0 → 0.15)
|
||||
flexibility_ratio = flexibility_pct / 100
|
||||
|
||||
result = []
|
||||
smoothed_count = 0
|
||||
|
||||
|
|
@ -225,7 +228,7 @@ def filter_price_outliers(
|
|||
|
||||
context_diff_pct = abs(avg_after - avg_before) / avg_before if avg_before > 0 else 0
|
||||
|
||||
if context_diff_pct > (flexibility_pct / 100):
|
||||
if context_diff_pct > flexibility_ratio:
|
||||
result.append(current)
|
||||
_LOGGER.debug(
|
||||
"%sInterval %s: Context unstable (%.1f%% change) - not a spike",
|
||||
|
|
|
|||
Loading…
Reference in a new issue