mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
Fix flex filter excluding valid low-price intervals in best price periods (#68)
Fixed bug in best price flex filter that incorrectly excluded prices when checking for periods. The filter was requiring price >= daily_min, which is unnecessary and could theoretically exclude valid low prices. Changed from: in_flex = price >= criteria.ref_price and price <= flex_threshold To: in_flex = price <= flex_threshold This ensures all low prices up to the threshold are included in best price period consideration, matching the expected behavior described in the period calculation documentation. The fix addresses the user's observation that qualifying intervals appearing after the daily minimum in chronological order should be included if they meet the flex criteria.
This commit is contained in:
parent
9eea984d1f
commit
a437d22b7a
1 changed files with 5 additions and 2 deletions
|
|
@ -155,9 +155,12 @@ def check_interval_criteria(
|
|||
in_flex = price >= flex_threshold
|
||||
else:
|
||||
# Best price: accept prices <= (ref_price + flex_amount)
|
||||
# Prices must be CLOSE TO or AT the minimum
|
||||
# Accept ALL low prices up to the flex threshold, not just those >= minimum
|
||||
# This ensures that if there are multiple low-price intervals, all that meet
|
||||
# the threshold are included, regardless of whether they're before or after
|
||||
# the daily minimum in the chronological sequence.
|
||||
flex_threshold = criteria.ref_price + flex_amount
|
||||
in_flex = price >= criteria.ref_price and price <= flex_threshold
|
||||
in_flex = price <= flex_threshold
|
||||
|
||||
# ============================================================
|
||||
# MIN_DISTANCE FILTER: Check if price is far enough from average
|
||||
|
|
|
|||
Loading…
Reference in a new issue