mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-07-27 17:26:48 +00:00
check_min_distance_from_avg() computed the distance threshold as range_avg * (1 ± ratio). Tibber prices can go negative during grid oversupply, and multiplying a negative range_avg directly flips the intended direction: e.g. avg * 1.05 makes a negative average MORE negative (i.e. cheaper), which is the wrong direction for a "most expensive" threshold check, and analogously wrong for "cheapest" checks. Compute the threshold as range_avg ± abs(range_avg) * ratio instead, matching the sign-safe normalization pattern already used for min_distance_from_avg in the period system (coordinator/period_handlers/level_filtering.py). Behavior for positive averages (the common case) is unchanged. Used by find_cheapest_block, find_cheapest_hours, and plan_charging. Impact: min_distance_from_avg now correctly filters cheapest/most expensive windows during negative-price periods instead of silently accepting windows in the wrong direction relative to the search range average. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_connect_segments.py | ||
| test_energy_calculator.py | ||
| test_find_cheapest_schedule_internals.py | ||
| test_find_service_responses.py | ||
| test_period_data_format.py | ||
| test_plan_charging.py | ||
| test_power_scheduler.py | ||
| test_search_range.py | ||
| test_sequential_scheduling.py | ||
| test_service_helpers.py | ||