hass.tibber_prices/tests/services
Julian Pawlowski b8e40bfa3b fix(services): prevent plan_charging overcharge from segment-constraint bridging
apply_segment_constraints could add far more grid energy than requested when
max_cycles_per_day or min_charge_duration_minutes forced bridging across
expensive gaps between cheap intervals. With max_cycles_per_day=1, isolated
cheap intervals were merged into one continuous segment by filling every gap
in between, without ever trimming the surplus back down, resulting in
achieved_soc_percent far above 100%.

Add a post-bridging trim step that removes segment-edge intervals (highest
price first) until total grid energy matches the requested target again,
while still respecting max_cycles_per_day/min_charge_duration_minutes and
never dropping below the target itself (fixed-power mode's expected
last-interval rounding overshoot is preserved).

A related edge case is also fixed: trimming could previously remove an
interval required to satisfy a must_reach_by deadline, silently flipping
deadline_met to False even though the overall energy target was still
reached. Deadline-critical intervals are now passed through as
protected_starts and are never removed during trimming.

Fixes #167

Impact: plan_charging no longer overcharges the battery/EV past the
requested target SoC when max_cycles_per_day or min_charge_duration_minutes
is set, and must_reach_by deadlines are honored even when those constraints
require bridging across expensive price gaps.
2026-07-04 17:43:04 +00:00
..
__init__.py feat(services): improve ApexCharts segment visualization and fix header display 2025-12-01 11:14:27 +00:00
test_connect_segments.py refactor(currency)!: rename major/minor to base/subunit currency terminology 2025-12-11 08:26:30 +00:00
test_energy_calculator.py feat(services): add plan_charging service for battery/EV scheduling 2026-04-20 21:43:41 +00:00
test_find_service_responses.py fix(services): preserve service call data through coordinator data fetch (#151) 2026-06-01 12:45:10 +02:00
test_period_data_format.py refactor(currency)!: rename major/minor to base/subunit currency terminology 2025-12-11 08:26:30 +00:00
test_plan_charging.py fix(services): prevent plan_charging overcharge from segment-constraint bridging 2026-07-04 17:43:04 +00:00
test_power_scheduler.py fix(services): prevent plan_charging overcharge from segment-constraint bridging 2026-07-04 17:43:04 +00:00
test_search_range.py feat(services): add power-profile-weighted window selection 2026-05-03 22:16:08 +00:00
test_sequential_scheduling.py feat(services): add power-profile-weighted window selection 2026-05-03 22:16:08 +00:00