Skip to content

## Fix feed-in price unit conversion, unify battery static price to ct/kWh - #286

Merged
ohAnd merged 3 commits into
developfrom
283-fix-feedin-price-unit-conversion
Aug 25, 2026
Merged

## Fix feed-in price unit conversion, unify battery static price to ct/kWh#286
ohAnd merged 3 commits into
developfrom
283-fix-feedin-price-unit-conversion

Conversation

@ohAnd

@ohAnd ohAnd commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Fixes: #283

Problem

price.feed_in_price is ct/kWh, but both the startup wiring
(eos_connect.py) and the hot-reload path (hot_reload.py) passed it
unconverted into BatteryPriceHandler.pv_cost_euro_per_kwh, which expects
€/kWh — inflating the PV opportunity cost, and the computed battery price,
by 100x whenever battery_price_include_feedin was enabled.

battery.price_euro_per_wh_accu was also the only user-facing price field
using €/Wh instead of ct/kWh.

Changes

  • Convert price.feed_in_price ct/kWh → €/kWh at both boundaries.
  • Remove the <0.1 EUR/ct auto-detection heuristic in FeedInPriceInterface
    — it silently guessed the unit and missed exactly this class of bug.
  • Rename battery.price_euro_per_wh_accubattery.price_ct_kwh_accu
    (ct/kWh). Internal engine and the EOS optimizer payload keep €/Wh.
  • One-time migration rescales (×100000) and moves any existing stored value,
    so configured prices survive the change.
  • Chart: display electricity price in ct/kWh (currency_minor_unit).
  • Docs: correct feed-in price unit in examples and field descriptions.

Testing

  • 1186 passed (full suite, browser tests excluded)
  • New TestBatteryPriceUnitMigration: fresh install, zero value, rescale+move,
    runs-only-once
  • Updated hot-reload test asserts 8.0 ct/kWh → 0.08 €/kWh

Breaking / upgrade note

Config key rename is handled automatically by the migration; no manual action
needed. Users who worked around the 100x bug by entering a €/kWh-scaled
feed-in price should re-check price.feed_in_price.

ohAnd added 3 commits August 25, 2026 08:22
BatteryPriceHandler.pv_cost_euro_per_kwh expects €/kWh, but both the
startup wiring in eos_connect.py and the hot-reload path in
hot_reload.py passed the raw ct/kWh config value through unconverted.
This inflated the PV opportunity-cost term, and therefore the
computed battery price, by 100x whenever battery_price_include_feedin
was enabled.

Also removes the fixed-price EUR/ct auto-detection heuristic in
FeedInPriceInterface: it silently guessed the unit based on a
magnitude threshold (<0.1) and missed exactly this class of mistake
for realistic ct/kWh values above that threshold.

Fixes: #283
price.feed_in_price is ct/kWh everywhere in the schema and code, but
two examples and one field description in the user guide showed or
implied €/kWh — the same mix-up reported in #283. Also clarifies that
feed_in_price is a price.* key, not a battery.* key, and that
battery_price_include_feedin must be enabled for it to take effect.
battery.price_euro_per_wh_accu was the only price the user types
directly into config that used €/Wh instead of ct/kWh, unlike every
other price field in the app — and its name no longer matched its
unit once switched. Renamed to battery.price_ct_kwh_accu and convert
at the same boundary already used for price.feed_in_price, keeping
the €/Wh-based internal engine and the EOS optimizer request payload
untouched.

Includes a one-time migration that moves and rescales any existing
installation's stored value under the new key so already-configured
prices survive the change.
@ohAnd
ohAnd force-pushed the 283-fix-feedin-price-unit-conversion branch from 388b5a3 to 1b87544 Compare August 25, 2026 18:43
@ohAnd
ohAnd merged commit 42039db into develop Aug 25, 2026
10 checks passed
@ohAnd
ohAnd deleted the 283-fix-feedin-price-unit-conversion branch August 25, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant