pluginbattery/tests
Michiel Berger 9e77b35ff4 Hybrid dispatcher: greedy self-consumption + per-day grid arbitrage
Single algorithm with two passes:

Pass 1 — greedy self-consumption (real-firmware default):
    For each hour, charge any surplus, discharge into any demand.
    This nails sunny days: battery fills from morning surplus, exports
    only after capacity is reached, drains during evening peak.

Pass 2 — daily price-spread arbitrage on the residual capacity:
    For each UTC day, repeatedly find the most profitable
    cheap-charge → expensive-discharge pair (positive after round-trip
    efficiency), execute it, recompute SoC trajectory, repeat until no
    profitable cycle remains. Discharge must fit within hourly demand
    for plug-in batteries (no grid push). Sees only that day's prices,
    matching what a Tibber/Frank-style smart-charging controller does
    with day-ahead price visibility.

Effect:
- Sunny weeks (June 17-19): unchanged — greedy fill + evening discharge.
- No-sun weeks (Feb 7+): now generates arbitrage savings instead of €0.
- Mixed weeks: greedy handles surplus, arbitrage handles the rest.

Updated: test_grid_arbitrage_kicks_in_on_no_sun_days replaces the prior
"greedy doesn't arbitrage" test; now verifies the dispatcher charges
cheap hours and discharges expensive ones when no PV is available.
2026-05-01 10:36:07 +02:00
..
test_sim.py Hybrid dispatcher: greedy self-consumption + per-day grid arbitrage 2026-05-01 10:36:07 +02:00
test_store_calc.py Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00