No description
Find a file
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
data/raw Battery timeline modal + switch to real 2025 data 2026-05-01 09:21:16 +02:00
docs Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
scripts timeline: label columns 'no-bat meter' / 'with-bat meter' to avoid confusion 2026-04-30 22:47:59 +02:00
src/pluginbattery Hybrid dispatcher: greedy self-consumption + per-day grid arbitrage 2026-05-01 10:36:07 +02:00
tests Hybrid dispatcher: greedy self-consumption + per-day grid arbitrage 2026-05-01 10:36:07 +02:00
.env.example Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
.gitignore Move custom batteries from web.py into data/raw/extra_batteries.json 2026-04-30 15:52:16 +02:00
CLAUDE.md Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
Dockerfile Dockerfile: gunicorn 2 workers x 4 threads (gthread) 2026-04-30 17:39:13 +02:00
Procfile Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
pyproject.toml Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
README.md Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00
uv.lock Initial import: home-battery ROI simulator + cracked thuisbatterijgids calc 2026-04-30 13:46:27 +02:00

pluginbattery

Backtest the actual ROI of a home battery against real historical electricity prices and solar irradiance.

Answers: "If I had owned this battery (plug-in or installed) over the last N years, what would it have actually saved me?"

See CLAUDE.md for project intent, open decisions, and assumptions.