Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
995da777ce | ||
|
|
4dcd9b0fc6 | ||
|
|
9c65ac2cf8 | ||
|
|
7796f168a9 |
@@ -25,6 +25,8 @@ if it has, it needs 0.10.0. Whoever deploys decides.
|
||||
| _this branch_ | TARIFF-13 - the capacity-tariff row's "quarter(s) banked" stops resetting to 0 at every restart, and a tied peak's quarter stops moving |
|
||||
| _this branch_ | TARIFF-11 - the add-on's account of the tariff plan stops flattering it, and the status page is graded as a surface |
|
||||
| _this branch_ | TARIFF-17 - a price component that varies by hour has somewhere to live, so a Walloon day/night network tariff can change which hour is cheapest |
|
||||
| _this branch_ | TARIFF-18 - `price_taxes_eur_kwh` stops shipping at half the real Flemish figure **⚠️ CHANGED DEFAULT** |
|
||||
| _this branch_ | TARIFF-16 - the injection leg stops being one number: an injection formula with its own coefficients, its own VAT and no floor under zero |
|
||||
|
||||
⚠️ **A CONFIG THAT STARTS ON THE CURRENT VERSION CAN BE REFUSED ON THE NEXT
|
||||
ONE.** TARIFF-07 withdraws `engie_dynamic`, `totalenergies_dynamic` and
|
||||
@@ -60,6 +62,108 @@ separate card. *(Annotated 2026-09-13: that card is **TARIFF-15**, below, and it
|
||||
shipped on this branch as `custom_formula`. It is still not an alias — the
|
||||
operator types their own coefficients; nothing is invented on their behalf.)*
|
||||
|
||||
### TARIFF-16 - the injection leg stops being one number
|
||||
|
||||
**`price_export_formula`: what a site is PAID for export, as `factor × index +
|
||||
offset` with its own coefficients, alongside the flat `export_price_eur_kwh`.**
|
||||
|
||||
⚠️ **THIS IS NOT A WRONG-TRADE FIX, AND SAYING SO IS PART OF SHIPPING IT.**
|
||||
`arbitrage.py` does not read `export_price_eur_kwh` at all — its own comment
|
||||
says so, and gives §9.3's near-zero Belgian injection price as the reason the
|
||||
economically sound trade on this market is *charge cheap to displace expensive
|
||||
import*. Both hours it compares are all-in **consumption** prices. So no trade
|
||||
this add-on takes today is decided by an injection price, and nothing here
|
||||
changes one. What it changes is what an operator is told, and what any future
|
||||
export-aware strategy rests on: OPT-06 and any export logic would otherwise
|
||||
inherit a scalar that cannot represent the market, and the 6% VAT asymmetry
|
||||
between the two legs would be invisible in the arithmetic. `test_price.py` 17h
|
||||
parses every module under `app/` and goes red the day something calls an
|
||||
injection reader, so that claim is graded rather than attested.
|
||||
|
||||
**The market publishes a line, not a number.** Verbatim off the cards: Eneco
|
||||
Zon & Wind Dynamisch `0,1 x BELPEX-H - 1,188` c€/kWh — *"Het injectietarief is
|
||||
dynamisch en kan per uur wijzigen"*, identical on the January and the September
|
||||
2026 cards; ENGIE Dynamic `(B x eSpot_15) - A`; Aspiravi `0,07 x Belpex - 2`.
|
||||
Four properties a scalar cannot hold:
|
||||
|
||||
1. **Its own factor.** Eneco `0,102` on consumption against `0,100` on
|
||||
injection; Aspiravi `0,07` against about `0,10` on its consumption leg. Not
|
||||
the consumption `B` with a sign flip.
|
||||
2. **A negative offset** — `− 1,188`, `− 2`. `price_markup_eur_kwh: float(0,1)`
|
||||
cannot express a negative markup at all, so it has no home on the
|
||||
consumption side either.
|
||||
3. **VAT-exempt** — *"Injectietarieven zijn vrijgesteld van btw"* — while
|
||||
consumption is at 6%. `vat_pct` is now **per leg**, so the six-point
|
||||
asymmetry is expressible; a scalar carries no VAT field at all.
|
||||
4. **It goes negative with no floor**, below `11,88 EUR/MWh` of BELPEX-H — the
|
||||
midday hours a PV household exports in. You can be charged to export.
|
||||
|
||||
⚠️ **A NEGATIVE INJECTION PRICE IS ACCEPTED, NOT REFUSED**, and that needed a
|
||||
different band rather than a lower floor. `implausible_all_in()` floors the
|
||||
consumption leg at `+0.02 EUR/kWh` of energy, which is right there and fatal
|
||||
here — measured, not assumed: `test_price.py` 17c puts one spec through **both**
|
||||
bands and prints that the consumption band refuses `−0.03008 EUR/kWh` while the
|
||||
injection band accepts it. The floor was not decoration, though: it is what
|
||||
catches a card read a hundred times too small, the one unit error the card
|
||||
self-check cannot see because it cancels out of a comparison between the two
|
||||
sides. So the bound moves **off the price and onto the coefficients**, where it
|
||||
is index-free and sign-free — a **pass-through** band (`factor` as a share of
|
||||
the wholesale price; Eneco's injection leg is 1.00×, Aspiravi's 0.70×, the band
|
||||
is 0.10–10×) and an **offset magnitude** bound (0.20 EUR/kWh against published
|
||||
values of 0.01188 and 0.02). Two rungs that can both answer a hundredfold
|
||||
error, so each is graded on its **reason**, each gets a stimulus the other
|
||||
cannot reach, and they are mutated **together** (TEST-16).
|
||||
|
||||
⚠️ **THE CARD SELF-CHECK APPLIES WHERE THERE IS A CARD, AND WHERE THERE IS NOT
|
||||
THAT IS STATED RATHER THAN WORKED AROUND.** `price_formula` can require a `card`
|
||||
block because a Belgian card prints the consumption formula, the reference index
|
||||
*and* the resulting price. **Eneco's injection formula is printed with no price
|
||||
beside it.** Requiring a block would make the market's own published line
|
||||
inexpressible; inventing the estimate would grade the coefficients against
|
||||
arithmetic done with the same coefficients. So the block is **optional on this
|
||||
leg and unchanged on the other**, the self-check runs at the same tolerance
|
||||
wherever a printed estimate exists, and validate.py says at startup —
|
||||
*"its coefficients are UNGRADED"* — when it does not, naming the two bounds that
|
||||
ran instead. This is TARIFF-15 demonstrating two tariffs end to end rather than
|
||||
three, one card later.
|
||||
|
||||
**ONE PARSER, NOT TWO.** `custom_formula.py` already shipped the units table,
|
||||
the NaN rule, the closed enumerations, the unknown-key refusal, the card
|
||||
comparison and `to_resolution()`'s DST handling, so `parse_export_formula()` is
|
||||
that parser with its **option name as an argument** — TARIFF-17's move on
|
||||
`parse_static_profile()`, exactly. Everything that differs between the two legs
|
||||
is a string in one `_LEGS` table. `test_price.py` 17b pins it two ways: by
|
||||
parsing every module under `app/` and asserting all 32 grammar names are defined
|
||||
in exactly **one** of them, and by deriving twelve refusal sentences for the new
|
||||
option from the old option's own sentence rather than transcribing them. The
|
||||
three sentences that deliberately **differ** are named, with what differs, and
|
||||
asserted to differ.
|
||||
|
||||
**NOTHING CHANGES FOR A SITE THAT DOES NOT SET IT.** The option ships `""`, and
|
||||
`export_price_eur_kwh()`'s body is byte-identical — pinned on the AST, not on
|
||||
the source text — with `export_price_at()` falling through to it for every index
|
||||
value. `test_price.py` 17f compares seven option dicts × five index values
|
||||
against the pre-TARIFF-16 expression with `==`.
|
||||
|
||||
`export_price_eur_kwh` and the new key are both in `FRAMEWORK_KEYS`;
|
||||
`BANNED_IN_PLUGIN_CODE` is derived from that set, so `code_leaks()` refuses a
|
||||
plugin that names either with nothing else edited.
|
||||
|
||||
**Also corrected here:** `config.yaml`'s comment beside `export_price_eur_kwh`
|
||||
still read *"no shipped supplier publishes a dynamic injection curve"*.
|
||||
TARIFF-07 struck that claim from `app/price.py` and `DOCS.md` and did not reach
|
||||
`config.yaml`, where it has been shipping since.
|
||||
|
||||
**20 mutations, every one red on a named check**, ledger in `test_price.py`
|
||||
below section 17 with byte deltas — including a **zero-byte** one (the two legs
|
||||
transposed in the VAT-asymmetry banner, which changes no decision and only
|
||||
moves the sentence) and a **one-byte** one (`card_required=True` on the
|
||||
injection leg). Three were run over all 29 files and are red on `test_price.py`
|
||||
alone; the rest over the five suites that can reach this card. Each row gets a
|
||||
fresh copy of the tree under a `mktemp` path, mounted `:ro` — no revert to fail
|
||||
and no shared backup path, which is MUTATION.md habit 18 closed structurally.
|
||||
29/29 green.
|
||||
|
||||
### TARIFF-17 - a price component that varies by hour has somewhere to live
|
||||
|
||||
**`price_taxes_profile`: the taxes component as a period table, alongside the
|
||||
@@ -131,6 +235,111 @@ figure is correct. This is a product concern rather than a site one: the add-on
|
||||
is sold to clients, and a Walloon or Brussels client could not express their
|
||||
own tariff.
|
||||
|
||||
### TARIFF-18 - `price_taxes_eur_kwh` stops shipping at half the real figure
|
||||
|
||||
⚠️ **A SHIPPED DEFAULT CHANGED: `price_taxes_eur_kwh` 0.06 -> 0.11736 EUR/kWh.**
|
||||
Same shape as 0.8.0's `slew_w` rule, and the same instruction follows — **read
|
||||
the live options before `ha addons update`**, this time to see whether
|
||||
`price_taxes_profile` is set, which is the one shape the move could have
|
||||
refused. The "who is affected" section below is the part that matters, and it
|
||||
is shorter on consequences than a changed default usually is.
|
||||
|
||||
The old `0.06` had **no recorded provenance anywhere**: not a card, not a date,
|
||||
not a component list. It is roughly **half** the Flemish figure. The new default
|
||||
is the Eneco residential card for Flanders, September 2026, incl. 6 % VAT, and
|
||||
its rows are now **in the code** (`app/price.py`'s
|
||||
`FLEMISH_TAXES_COMPONENTS_EUR_KWH`, re-added by `test_price.py` section 1b):
|
||||
|
||||
| component | c€/kWh |
|
||||
|---|---|
|
||||
| Fluvius distribution (**Antwerpen**) | 5,35 |
|
||||
| Bijzondere accijns, *"Alle verbruik"* — no volume bands | 4,876 |
|
||||
| Bijdrage groene stroom en WKK Vlaanderen | 1,51 |
|
||||
| Energiebijdrage — **0 EUR/MWh since 2026-08-01**, merged into the accijns | 0 |
|
||||
| **total** | **11,736 c€/kWh = 0.11736** |
|
||||
|
||||
⚠️ **IT IS PER-DSO, AND THE DEFAULT IS NOT AN AVERAGE.** Only the distribution
|
||||
row moves: across the eight Fluvius DSOs it runs 5,28 c€/kWh
|
||||
(Midden-Vlaanderen) to 6,70 (West), so the Flemish total runs about **0.117 to
|
||||
0.131**. The default is a real DSO's real row, near the **low** end, and DOCS
|
||||
tells an operator to look up their own. A **Walloon or Brussels** site should
|
||||
not use this scalar at all — its distribution tariff has a day and a night band
|
||||
and belongs in TARIFF-17's `price_taxes_profile`.
|
||||
|
||||
⚠️ **THIS IS A DISPLAY AND GUARD FIX. IT DOES NOT IMPROVE ARBITRAGE AND CANNOT.**
|
||||
This scalar is a **LEVEL** component: an additive constant cancels exactly in
|
||||
`max − min` and leaves the argmin where it was. TARIFF-17 shipped the machinery
|
||||
and the proof — six flat scalars spanning and exceeding the whole per-DSO range
|
||||
give the **identical** cheapest hour and the **identical** spread to the last
|
||||
digit (`test_price.py` 16b, printed on every run), and none of that changes
|
||||
here. No trade happens that did not happen before *because of the level*. What
|
||||
does change is two things, and nothing else:
|
||||
|
||||
* **every number an operator reads** — the all-in prices on the status page,
|
||||
`custom_formula`'s startup preview and the recorded price history. At half
|
||||
the true non-energy component they made the add-on look considerably better
|
||||
than it is; and
|
||||
* **§17's negative-price guard** (`arbitrage.py`), the one rung that tests an
|
||||
**absolute** all-in price rather than a difference. It fires when
|
||||
`spot < −(markup + taxes)`, so its boundary moves **−0.09000 -> −0.14736
|
||||
EUR/kWh of spot**. A −0.11868 EUR/kWh spot hour used to read **−0.02868**
|
||||
all-in and the discharge was refused as paid-for disposal; at the real tax
|
||||
level it reads **+0.02868** and discharges, because that hour genuinely
|
||||
paid.
|
||||
`test_arbitrage.py` section 2c drives both sides through the shipped
|
||||
`decide()`, and pins the boundary from below as well.
|
||||
|
||||
⚠️ **AND THAT ASYMMETRY IS WHY THE DEFAULT SITS AT THE BOTTOM OF THE BAND.** Set
|
||||
too **high**, the figure carries a genuinely negative hour above zero and the
|
||||
add-on exports into paid-for disposal — §17's own case. Set too **low**, it only
|
||||
declines a discharge that would have paid. One default standing in for eight
|
||||
DSOs belongs at the bottom.
|
||||
|
||||
#### Who is affected
|
||||
|
||||
* **A site that set `price_taxes_eur_kwh` itself: nothing changes.** Its value
|
||||
is kept and is never silently replaced.
|
||||
* **A site whose stored options blob already carries the key: nothing changes
|
||||
either, and this is most existing installs.** The Supervisor sets
|
||||
`App.options = deepmerge(config.yaml defaults, stored options)`
|
||||
(`tools/supervisor_selfapi_probe.py` §D), so a moved default reaches only
|
||||
keys the blob does **not** carry — and the reference install's export carries
|
||||
**70 of the 71**, the one absentee being a key added after its last save.
|
||||
Such a site goes on running at `0.06` and reading numbers that are about half
|
||||
its real all-in price until somebody opens the Configuration tab. ⚠️ **That
|
||||
is a real limit of this card and it is not fixed here**: the change reaches a
|
||||
**fresh install**, and an existing one only when its options are re-saved.
|
||||
⚠️ **NOT re-measured on this branch** — the 70-of-71 figure is 0.9.0's, and
|
||||
PKG-09's `tools/predeploy_check.py --options <live blob>` against the live
|
||||
options is what would confirm it before deploying.
|
||||
* ⚠️ **A site with `price_taxes_profile` SET would have been refused at startup,
|
||||
and is deliberately not.** TARIFF-17 made a taxes period table beside a
|
||||
**non-default** `price_taxes_eur_kwh` a `SystemExit(78)` refusal, comparing
|
||||
against the shipped default precisely because the Supervisor writes the key
|
||||
whether it was typed or not. Moving the default turns every stored `0.06`
|
||||
into "non-default" **without anybody editing anything**, so a working Walloon
|
||||
or Brussels site would have stopped starting on the upgrade over an inert
|
||||
number the table overrides anyway. `price.py` now carries
|
||||
`SUPERSEDED_TAXES_DEFAULTS_EUR_KWH = (0.06,)` and `validate.py` treats a
|
||||
superseded default as *untouched* as well. **The rung is not weakened**: a
|
||||
figure that is neither the shipped nor a superseded default — ORES's 0.1198,
|
||||
say — is still refused, by name, and the refusal now says which of the two
|
||||
figures it will accept (`test_validate.py`, four new checks plus the
|
||||
difference precondition).
|
||||
|
||||
Nothing hardcoded `0.06` in that rung — it read `PRICE_OPTION_DEFAULTS` — which
|
||||
is why the interaction is a *behaviour* change rather than a drift, and why it
|
||||
had to be decided rather than noticed.
|
||||
|
||||
`config.yaml` and `PRICE_OPTION_DEFAULTS` moved together and CFG-03's tripwire
|
||||
(`test_price.py` section 1, `test_defaults_pin.py`) stayed green by agreeing,
|
||||
not by being widened. ⚠️ One check did have to be **rewritten rather than
|
||||
re-pointed**: `test_price.py` section 0 used to justify its own grading
|
||||
constants by observing that the shipped pair was degenerate — `0.06` is exactly
|
||||
twice `0.03`. TARIFF-18 ends that coincidence, so the sentence is no longer true
|
||||
and is not kept; the file now asserts per-figure that neither shipped default is
|
||||
what it grades with, which is the property that was actually load-bearing.
|
||||
|
||||
### TARIFF-13 - the coverage figure beside the peak, and which quarter gets it
|
||||
|
||||
**The capacity-tariff status row's `N quarter(s) banked` is read from the
|
||||
|
||||
@@ -85,11 +85,14 @@ refusal: the card's own point must land inside 0.02–1.00 EUR/kWh.
|
||||
|
||||
⚠️ **Its floor is applied to the ENERGY figure and not to the all-in one, and
|
||||
that asymmetry was found by a mutation rather than by reasoning.** The shipped
|
||||
`price_taxes_eur_kwh` is 0.06 — three times the floor — so a card read a
|
||||
`price_taxes_eur_kwh` was 0.06 — three times the floor — so a card read a
|
||||
hundred times too small comes out at 0.0016 EUR/kWh of energy, is carried over
|
||||
0.02 by the flat tax addend alone, and passes a band applied to the total. The
|
||||
hundredfold error is exactly what the band exists for. Graded from both
|
||||
directions in `test_price.py` 15e/15i and driven red as M10.
|
||||
directions in `test_price.py` 15e/15i and driven red as M10. *(Annotated
|
||||
2026-09-13: TARIFF-18 raised the default to 0.11736, nearly six times the
|
||||
floor. The asymmetry is unchanged in kind and larger in degree — the flat
|
||||
addend that carries a hundredfold-small card over 0.02 got bigger.)*
|
||||
|
||||
## 4. Fixed coefficients. No expression evaluation of any kind
|
||||
|
||||
@@ -155,4 +158,9 @@ granularity it was handed. Graded.
|
||||
* **The hour-varying network charge that bites Wallonia.** Separate card.
|
||||
* **Raising `price_taxes_eur_kwh` from 0.06 to ~0.12.** Separate card, and an
|
||||
owner's decision. Note §3b: the band's floor is deliberately insensitive to
|
||||
whatever that number becomes.
|
||||
whatever that number becomes. *(Annotated 2026-09-13: that card is
|
||||
**TARIFF-18** and it shipped on this branch at **0.11736** — the Eneco
|
||||
residential card for Flanders, September 2026, incl. 6 % VAT, summed from
|
||||
Fluvius Antwerpen distribution 5,35 + bijzondere accijns 4,876 + bijdrage
|
||||
groene stroom en WKK 1,51 c€/kWh. §3b held: the floor is still on the energy
|
||||
figure and nothing in this module needed a new number.)*
|
||||
|
||||
+214
-29
@@ -1371,8 +1371,9 @@ does, and only after you have read why.
|
||||
|---|---|
|
||||
| `price_provider` | `off` (default) or one of the three plugins below |
|
||||
| `price_markup_eur_kwh` | Your supplier's margin, EUR/kWh. **Added only when the chosen plugin's feed does not already contain it** |
|
||||
| `price_taxes_eur_kwh` | Levies and VAT, EUR/kWh. Same rule |
|
||||
| `export_price_eur_kwh` | The **injection** price. A separate scalar, not a series — see below |
|
||||
| `price_taxes_eur_kwh` | Distribution, levies and VAT, EUR/kWh. Same rule. Defaults to **0.11736** — a real Flemish figure, and **yours is probably different**: see *What `price_taxes_eur_kwh` is made of* below |
|
||||
| `export_price_eur_kwh` | The **flat injection** price, EUR/kWh. May be negative — see below |
|
||||
| `price_export_formula` | The **injection formula**, if your contract has one. Same shape as `price_formula`, its own coefficients, its own `vat_pct` — see below |
|
||||
| `price_csv_path` | Where `manual_csv` reads its file |
|
||||
| `price_feed_url` | Override the plugin's default feed. Used **exactly as written** — the add-on appends nothing to it, including the date range, so an override gets whatever horizon that URL returns. Only a host the plugin itself declares is accepted |
|
||||
| `price_horizon_h` | How far ahead to ask for, hours |
|
||||
@@ -1691,10 +1692,13 @@ the default markup and taxes, not an illustration.)
|
||||
|
||||
##### What it does not do
|
||||
|
||||
The **injection** leg is a separate card. Eneco uses `0,102` on consumption and
|
||||
The **injection** leg is a separate card, and it has its own option:
|
||||
`price_export_formula` (TARIFF-16). Eneco uses `0,102` on consumption and
|
||||
`0,100` on injection, and injection is VAT-exempt where consumption is at 6 %,
|
||||
so it is a second per-contract formula rather than a second copy of this one.
|
||||
`export_price_eur_kwh` is still the scalar you enter by hand.
|
||||
so it is a second per-contract formula rather than a second copy of this one —
|
||||
the same parser, its own coefficients. `export_price_eur_kwh` remains the flat
|
||||
injection price for a site that is paid one, and **no strategy reads either**;
|
||||
see *Injection is priced separately* above.
|
||||
|
||||
#### `manual_csv` — the offline fallback
|
||||
|
||||
@@ -1845,25 +1849,122 @@ logged and reported on the status row, never raised. A cache that cannot answer
|
||||
is not allowed to be a controller that cannot regulate, and that applies to the
|
||||
volume being full exactly as it applies to the volume being absent.
|
||||
|
||||
**Injection is priced separately** (`export_price_eur_kwh`). In Belgium it is
|
||||
often near zero, which by itself strongly favours self-consumption over export.
|
||||
Negative values are accepted — you can be paid to *not* export at midday in
|
||||
summer.
|
||||
### Injection is priced separately
|
||||
|
||||
⚠️ It is a single number rather than a curve, and the reason given here until
|
||||
TARIFF-07 — *"no supported supplier publishes a dynamic injection tariff"* — was
|
||||
**false**. Suppliers do. Eneco publishes `0,1 x BELPEX-H − 1,188` on the same
|
||||
tariff card as its consumption formula (identical on the January and the
|
||||
September 2026 cards), and ENGIE publishes one in the same shape,
|
||||
`(B x eSpot_15) − A`. What is true is narrower: an injection curve is the **same
|
||||
two-coefficient formula** as the consumption curve but with **its own**
|
||||
coefficients and **its own VAT treatment** — injection is VAT-exempt where
|
||||
consumption is at 6% — so it is a second per-contract formula rather than a copy
|
||||
of the first, and the add-on cannot evaluate either one yet. Until the formula
|
||||
provider ships, **this scalar is a simplification you enter by hand — an average
|
||||
of what you are actually paid — and not a reflection of the market.**
|
||||
There are two ways to say what you are paid for an exported kWh, and which one
|
||||
you want depends on your contract:
|
||||
|
||||
**The old Home Assistant price sensors.** `price_now_entity` and
|
||||
| your contract | what to set |
|
||||
|---|---|
|
||||
| a flat injection price | `export_price_eur_kwh` — one number, EUR/kWh. This is the default and what every existing install uses |
|
||||
| a price that moves with the market | `price_export_formula` — your card's injection line as `factor × index + offset`, in exactly the shape `price_formula` uses for consumption |
|
||||
|
||||
Negative values are accepted on both — you can be charged to export at midday in
|
||||
summer, and the add-on says so rather than flooring it.
|
||||
|
||||
#### ⚠️ What the add-on does *not* do with an injection price
|
||||
|
||||
**No strategy in this add-on reads one.** Not the scalar, not the formula.
|
||||
`arbitrage.py` prices the sell side as **displaced import** — both hours it
|
||||
compares are all-in *consumption* prices — and its own comment gives the reason:
|
||||
§9.3's near-zero Belgian injection price is exactly why the economically sound
|
||||
trade on this market is *charge cheap to displace expensive import*, not *charge
|
||||
cheap to export dear*. So setting `price_export_formula` changes **no decision
|
||||
the add-on takes today**. It changes what you are shown at startup, and it is
|
||||
the shape any future export-aware strategy would read.
|
||||
|
||||
That is the argument for doing it now rather than later: OPT-06 and any export
|
||||
logic would otherwise inherit a scalar that cannot represent the market, and the
|
||||
6% VAT asymmetry between the two legs would be invisible in the arithmetic.
|
||||
`test_price.py` 17h parses every module under `app/` and goes red the day
|
||||
something calls an injection reader, so this paragraph is graded rather than
|
||||
attested.
|
||||
|
||||
#### Why a scalar was not enough
|
||||
|
||||
Belgian suppliers publish the injection leg as a formula, on the same card as
|
||||
the consumption one. The reason given here until TARIFF-07 — *"no supported
|
||||
supplier publishes a dynamic injection tariff"* — was **false**, and what they
|
||||
publish has four properties one number cannot hold:
|
||||
|
||||
```
|
||||
Eneco Zon & Wind Dynamisch 0,1 x BELPEX-H - 1,188 c/kWh
|
||||
"Het injectietarief is dynamisch en kan per uur wijzigen"
|
||||
- identical on the January and the September 2026 cards
|
||||
ENGIE Dynamic (B x eSpot_15) - A
|
||||
Aspiravi (non-dynamic) 0,07 x Belpex - 2
|
||||
```
|
||||
|
||||
1. **Its own factor.** Eneco uses `0,102` on consumption and `0,100` on
|
||||
injection; Aspiravi `0,07` against about `0,10` on its consumption leg. It is
|
||||
**not** the consumption `B` with a sign flip.
|
||||
2. **A negative offset** — `− 1,188`, `− 2`. Note that
|
||||
`price_markup_eur_kwh: float(0,1)` cannot express a negative markup at all,
|
||||
so the offset has no home on the consumption side either.
|
||||
3. **VAT-exempt.** *"Injectietarieven zijn vrijgesteld van btw"*, while
|
||||
consumption is at 6%. `vat_pct` is **per leg**, so that six-point asymmetry
|
||||
is expressible; a single scalar carries no VAT field at all.
|
||||
4. **It goes negative, with no floor.** Eneco's injection price is below zero
|
||||
for any BELPEX-H under **11,88 EUR/MWh** — and a PV household exports
|
||||
precisely in the hours most likely to be negative. **You can be charged to
|
||||
export.**
|
||||
|
||||
#### `price_export_formula`, field by field
|
||||
|
||||
Same grammar as `price_formula` — literally the same parser, with its option
|
||||
name as an argument, so there is no second unit table and no second card rule to
|
||||
diverge from the first. Eneco's published injection line, typed out:
|
||||
|
||||
```json
|
||||
{"index":"epex_be","resolution":"hourly","factor":0.1,"offset":-1.188,
|
||||
"units":"c_eur_per_kwh","vat_pct":0}
|
||||
```
|
||||
|
||||
⚠️ **`vat_pct` is 0 here and 6 on the consumption leg.** That is the one field
|
||||
people copy across from the other formula and get wrong.
|
||||
|
||||
⚠️ **The `card` block is optional on this leg and required on the other**, and
|
||||
that is a statement about the cards rather than a relaxed rule. `price_formula`
|
||||
can demand one because a Belgian card prints the consumption formula, the
|
||||
reference index it assumed *and* the resulting price — so the add-on can
|
||||
recompute that price and refuse to start unless your numbers reproduce it.
|
||||
**Eneco's injection formula is printed with no price beside it.** There is
|
||||
nothing to grade against on that card. Requiring a block would make the market's
|
||||
own published line inexpressible; inventing the estimate would grade your
|
||||
coefficients against arithmetic done with your coefficients, which is not a
|
||||
check. So:
|
||||
|
||||
* if **your** card prints an injection estimate, fill the block in and it is
|
||||
graded at the same tolerance as the consumption leg — the add-on refuses to
|
||||
start if your numbers do not reproduce it;
|
||||
* if it does not, the add-on **says so at startup** — *"its coefficients are
|
||||
UNGRADED"* — and names what it checked instead.
|
||||
|
||||
What it checks instead, always, on both paths:
|
||||
|
||||
* **pass-through**: `factor`, converted to a share of the wholesale price, must
|
||||
be between 0.10× and 10×. Eneco's injection leg is `1.00×` and Aspiravi's
|
||||
`0.70×`; a coefficient typed a hundred times out reads `0.01×` or `100×`.
|
||||
* **offset magnitude**: `|offset|` must be at most 0.20 EUR/kWh. The published
|
||||
ones are `−0.01188` and `−0.02`.
|
||||
|
||||
Both bounds are on the **coefficients**, not on the price, which is why they can
|
||||
bound a leg whose price legitimately goes below zero. `price_formula`'s
|
||||
plausibility band is deliberately **not** reused here: its floor is `+0.02
|
||||
EUR/kWh` of energy, and applying that to injection would refuse the real market
|
||||
in exactly the hours where knowing the number matters most.
|
||||
|
||||
⚠️ **And the gap those bounds leave, with its size.** They bound the *shape* of
|
||||
the coefficients, never their truth. With no printed estimate, a `factor` of
|
||||
`0.070` where your contract says `0.100` — 30% of every export payment — passes
|
||||
both, because `0.70×` is a pass-through somebody really publishes. Only a
|
||||
printed estimate can catch a wrong-contract pair, and on Eneco's card there is
|
||||
not one. That is why the startup line says the leg is ungraded instead of
|
||||
implying it was checked.
|
||||
|
||||
### The old Home Assistant price sensors
|
||||
|
||||
`price_now_entity` and
|
||||
`price_avg_entity` still work and are unchanged: the add-on compares them and
|
||||
uses the result as a cheap-window hint for the maintenance charge. They are
|
||||
**not compatible with `price_provider`, and not with `static_profile` either**
|
||||
@@ -1891,10 +1992,11 @@ size:
|
||||
| **ORDER** | **varies** by hour, block or day-type | **Yes, and worst.** It changes *which hour is cheapest* |
|
||||
|
||||
Measured on the real arithmetic (`test_price.py` section 16b, printed on every
|
||||
run): with a flat taxes figure of 0.00, 0.0739, 0.1198, 0.1327 or 1.00 EUR/kWh,
|
||||
the same 24-hour feed is cheapest at **13:00 in all five cases** and its spread
|
||||
is **0.1500 EUR/kWh in all five cases**. That is the LEVEL bucket doing
|
||||
nothing, and it is not a rounding artefact — it is arithmetic.
|
||||
run): with a flat taxes figure of 0.00, 0.0739, 0.11736 (the shipped default),
|
||||
0.1198, 0.1327 or 1.00 EUR/kWh, the same 24-hour feed is cheapest at **13:00 in
|
||||
all six cases** and its spread is **0.1500 EUR/kWh in all six cases**. That is
|
||||
the LEVEL bucket doing nothing, and it is not a rounding artefact — it is
|
||||
arithmetic.
|
||||
|
||||
Three consequences worth having in mind:
|
||||
|
||||
@@ -1925,6 +2027,83 @@ Three consequences worth having in mind:
|
||||
is the only ORDER component the add-on has. Anything added next belongs in one
|
||||
of the three, and saying which is part of adding it.
|
||||
|
||||
### What `price_taxes_eur_kwh` is made of, and why yours is different (TARIFF-18)
|
||||
|
||||
**It ships at `0.11736` EUR/kWh.** That is the all-in non-energy part of a
|
||||
Flemish residential bill — everything on your invoice that is *not* the energy
|
||||
itself — read off the Eneco residential card for Flanders, **September 2026**,
|
||||
**including 6 % VAT**:
|
||||
|
||||
| component | c€/kWh |
|
||||
|---|---|
|
||||
| Fluvius distribution (**Antwerpen**) | 5,35 |
|
||||
| Bijzondere accijns, *"Alle verbruik"* — no volume bands | 4,876 |
|
||||
| Bijdrage groene stroom en WKK Vlaanderen | 1,51 |
|
||||
| Energiebijdrage | **0** |
|
||||
| **total** | **11,736 c€/kWh = 0.11736 €/kWh** |
|
||||
|
||||
The rows are in the code, in `app/price.py`'s
|
||||
`FLEMISH_TAXES_COMPONENTS_EUR_KWH`, and `test_price.py` section 1b re-adds them
|
||||
and refuses a default that is not their sum. It replaces a shipped `0.06`,
|
||||
which was roughly **half** the true figure and had no recorded provenance at
|
||||
all.
|
||||
|
||||
⚠️ **`energiebijdrage` is zero and that is not a mistake.** *"Vanaf 1 augustus
|
||||
2026 bedraagt de energiebijdrage 0 EUR/MWh"* — it was merged into the
|
||||
bijzondere accijns. If you are re-deriving this total from a guide written
|
||||
before that date you will find a separate energiebijdrage line; adding it would
|
||||
count it twice. It is carried as a **zero row** rather than left out for
|
||||
exactly that reason.
|
||||
|
||||
⚠️ **THIS IS A PER-DSO FIGURE AND YOURS IS PROBABLY NOT 0.11736.** Only the
|
||||
distribution row moves. Across the eight Fluvius DSOs it runs **5,28 c€/kWh**
|
||||
(Midden-Vlaanderen) to **6,70** (West), so the Flemish all-in total runs about
|
||||
**0.117 to 0.131 €/kWh** — a 1,42 c€/kWh spread, which on 4 000 kWh a year is
|
||||
about €57. The other two rows are Flanders-wide and do not move. **Look up your
|
||||
own distribution row, add the same accijns and groenestroombijdrage, and type
|
||||
the total.**
|
||||
|
||||
⚠️ **A WALLOON OR BRUSSELS SITE SHOULD NOT USE THIS SCALAR AT ALL.** Their
|
||||
distribution tariff has a **day and a night band** — `Enkelvoudig | Dag |
|
||||
Nacht | Uitsl. nacht` on the same card, where Fluvius prints a single rate —
|
||||
and a flat figure flattens exactly the component that is anti-correlated with
|
||||
what the battery wants to do. Use **`price_taxes_profile`** (the next section);
|
||||
it is the only ORDER-bucket component the add-on has.
|
||||
|
||||
⚠️ **THIS IS A DISPLAY AND GUARD FIX. IT DOES NOT IMPROVE ARBITRAGE, AND IT
|
||||
CANNOT.** `price_taxes_eur_kwh` is a **LEVEL** component — added identically to
|
||||
every hour — so it **cancels exactly** in `max − min` and leaves the argmin
|
||||
where it was. It does not change which hour is cheapest, it does not change the
|
||||
spread, and it does not make any trade happen that did not happen before. See
|
||||
*The three buckets* above, where six flat scalars spanning and exceeding the
|
||||
whole per-DSO range give the identical cheapest hour and the identical spread
|
||||
to the last digit. What raising it **does** change is exactly two things:
|
||||
|
||||
* **every figure an operator reads** — the all-in prices on the status page,
|
||||
`custom_formula`'s startup preview and the recorded price history. At half
|
||||
the true non-energy component they made the add-on look considerably better
|
||||
than it is.
|
||||
* **§17's negative-price guard** (`arbitrage.py`), which is the one rung that
|
||||
tests an **absolute** all-in price rather than a difference. The guard fires
|
||||
when `spot < −(markup + taxes)`, so its boundary moved from **−0.09000** to
|
||||
**−0.14736 €/kWh** of spot. A spot hour at −0.11868 €/kWh used to read
|
||||
**−0.02868 €/kWh** all-in and the discharge was refused as paid-for disposal;
|
||||
at the real tax level it reads **+0.02868** and the discharge is allowed,
|
||||
because the operator really does pay those levies and that hour really was
|
||||
profitable (`test_arbitrage.py` section 2c drives both, and pins the boundary
|
||||
from below as well).
|
||||
|
||||
⚠️ **Which is why the default sits near the LOW end of the per-DSO band rather
|
||||
than in the middle of it.** The two error directions are not symmetric. Set too
|
||||
**high**, the figure carries a genuinely negative hour up above zero and the
|
||||
add-on exports into paid-for disposal — §17's own regression case. Set too
|
||||
**low**, it only declines a discharge that would have paid. Where one default
|
||||
has to stand in for eight DSOs, it belongs at the bottom.
|
||||
|
||||
**If you set this yourself, nothing above affects you.** A site with its own
|
||||
`price_taxes_eur_kwh` keeps it; the default only answers where the option is
|
||||
absent from the stored options blob.
|
||||
|
||||
### Levies and VAT by time of day (`price_taxes_profile`)
|
||||
|
||||
**Leave this empty unless your network tariff really does have a day and a
|
||||
@@ -1979,8 +2158,12 @@ second set of 23- and 25-hour-day bugs.
|
||||
- ⚠️ **Set this *or* `price_taxes_eur_kwh`, not both.** The table wins when it
|
||||
is set, so a scalar left at a non-default value beside it would be a number
|
||||
you typed that decides nothing. That is refused at startup rather than
|
||||
silently resolved; leave `price_taxes_eur_kwh` at its shipped `0.06` when you
|
||||
fill this in.
|
||||
silently resolved; leave `price_taxes_eur_kwh` at its shipped `0.11736` when
|
||||
you fill this in. ⚠️ **A scalar still sitting on the superseded `0.06` is
|
||||
also accepted**, and deliberately so — TARIFF-18 moved that default, and your
|
||||
stored options blob carries the old number whether you typed it or not, so
|
||||
refusing it would have stopped working Walloon and Brussels sites on an
|
||||
upgrade over a figure the table overrides anyway.
|
||||
- A **malformed table is refused at startup**, not at the next fetch. It is
|
||||
read on the ~30 s planning path, and a table that first fails at 03:00 is a
|
||||
site that stops pricing at 03:00 — which §11.4 turns into a quiet fallback
|
||||
@@ -1991,7 +2174,9 @@ second set of 23- and 25-hour-day bugs.
|
||||
is untouched — the table is routed through the same `capabilities().adds`
|
||||
rule as the scalar, not bolted on.
|
||||
- It does **not** apply to `static_profile`, whose prices are already all-in,
|
||||
nor to `export_price_eur_kwh`.
|
||||
nor to `export_price_eur_kwh` or `price_export_formula`. Those are the
|
||||
injection leg, and nothing is added to what you are *paid* for export:
|
||||
`price_taxes_eur_kwh` is a consumption component.
|
||||
|
||||
### Static day/night and fully-fixed tariffs (`static_profile`)
|
||||
|
||||
|
||||
@@ -831,13 +831,16 @@ document (`' 216.080 -> 0.30123'`), and M13 is red.
|
||||
|
||||
**M10 is `+0 B` and it is a real defect, not a synthetic one.** It came out of
|
||||
writing the mutation rather than out of review: `implausible_all_in()`'s floor
|
||||
was applied to the all-in figure, and `price_taxes_eur_kwh` ships at 0.06 —
|
||||
was applied to the all-in figure, and `price_taxes_eur_kwh` shipped at 0.06 —
|
||||
**three times the 0.02 floor** — so a card read a hundred times too small
|
||||
(0.0016 EUR/kWh of energy) is carried over the floor by the flat tax addend
|
||||
alone and passes. The hundredfold error is exactly what that band exists for.
|
||||
The floor is applied to the **energy** figure now and the ceiling to the all-in
|
||||
one, both directions are graded, and the trap is stated as a check in its own
|
||||
right so the asymmetry cannot be "tidied up" later.
|
||||
right so the asymmetry cannot be "tidied up" later. *(Annotated 2026-09-13:
|
||||
TARIFF-18 raised that default to 0.11736, **nearly six times** the floor. The
|
||||
addend that does the carrying got BIGGER, so the trap is wider than when M10
|
||||
was measured and the asymmetry is more load-bearing rather than less.)*
|
||||
|
||||
**M15 is the one the framework CANNOT catch, and the reds say which half does.**
|
||||
Declaring `ALL_IN` makes `assemble()` add nothing, and section 3's all-in check
|
||||
|
||||
@@ -125,6 +125,49 @@ units and the market aggregator prints both conventions in one column, so the
|
||||
add-on has to be told which one the card is in - and the unit conversion is the
|
||||
add-on's job precisely because it is one of the two steps that silently costs a
|
||||
factor of 10, 100 or 1000. The other is VAT, which is also the add-on's.
|
||||
|
||||
TARIFF-16 - THE SECOND LEG, AND WHY IT IS THIS PARSER AND NOT A SECOND ONE
|
||||
==========================================================================
|
||||
A Belgian dynamic contract has TWO published lines, not one, and the second is
|
||||
what the site is PAID for export:
|
||||
|
||||
Eneco Zon & Wind Dynamisch 0,1 x BELPEX-H - 1,188 c EUR/kWh
|
||||
ENGIE Dynamic (B x eSpot_15) - A
|
||||
Aspiravi (non-dynamic) 0,07 x Belpex - 2
|
||||
|
||||
Same `B x index + A` shape - which is why `price_export_formula` is this
|
||||
module's parser with ONE argument moved (`option`), exactly as TARIFF-17 made
|
||||
`parse_static_profile()`'s option name a parameter rather than forking the
|
||||
period grammar. What differs between the two legs is FOUR numbers and a
|
||||
handful of sentences, and all of them are rows of `_LEGS`:
|
||||
|
||||
* its OWN factor - Eneco 0,102 on consumption against 0,100 on injection,
|
||||
Aspiravi 0,07 against ~0,10. NOT the consumption `B` with a sign flip;
|
||||
* a NEGATIVE offset, which `factor`/`offset` already allow and which
|
||||
`price_markup_eur_kwh: float(0,1)` cannot express at all;
|
||||
* `vat_pct: 0` - "Injectietarieven zijn vrijgesteld van btw" - against 6 on
|
||||
consumption, which is a SIX PERCENT ASYMMETRY between the buy leg and the
|
||||
sell leg and is representable only because `vat_pct` is PER SPEC;
|
||||
* a price that goes BELOW ZERO with no floor, in the hours a PV household
|
||||
exports. `implausible_injection()` is the band that accepts that and still
|
||||
refuses an implausible one; `implausible_all_in()` is NOT it, and its
|
||||
docstring says why.
|
||||
|
||||
⚠️ AND THE CARD CANNOT ALWAYS GRADE IT. Eneco's injection formula is printed
|
||||
with NO price beside it, so on that card there is nothing to reproduce. The
|
||||
`card` block is therefore OPTIONAL on this leg and REQUIRED on the other, the
|
||||
self-check runs wherever there is a printed estimate, and validate.py says at
|
||||
startup when a leg is ungraded. Inventing an estimate to grade against would
|
||||
be grading arithmetic against itself, which is the defect MUTATION.md habit 4
|
||||
is about; TARIFF-15 demonstrated two tariffs end to end rather than three for
|
||||
the same reason.
|
||||
|
||||
⚠️ NOTHING TRADES ON THIS TODAY, AND SAYING SO IS PART OF SHIPPING IT.
|
||||
`arbitrage.py` does not read `export_price_eur_kwh` at all - its own comment
|
||||
says so, citing §9.3's near-zero Belgian injection price - and both hours it
|
||||
compares are all-in CONSUMPTION prices. So this is not a wrong-trade defect
|
||||
and must not be described as one. What it changes is what an operator is told,
|
||||
and what a future export-aware strategy would rest on.
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -183,6 +226,150 @@ _CARD_KEYS = ("month", "index_eur_per_mwh", "expect_incl_vat")
|
||||
_TOP_KEYS = ("index", "resolution", "factor", "offset", "units", "vat_pct",
|
||||
"card")
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# TARIFF-16 - the SECOND leg, and the one parameter that carries it
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
EXPORT_FORMULA_OPTION = "price_export_formula"
|
||||
|
||||
# ⚠️ THE PASS-THROUGH FRACTION, WHICH IS WHY THE NEXT TWO BOUNDS CAN BE
|
||||
# INDEX-FREE. One EUR/MWh IS 0.001 EUR/kWh, so `factor x UNITS[units] / 0.001`
|
||||
# is the dimensionless share of the wholesale price the contract passes
|
||||
# through - 1.00 for Eneco's injection leg (0,100 c EUR/kWh per EUR/MWh), 0.70
|
||||
# for Aspiravi's (0,07). A coefficient typed a hundred times too small or too
|
||||
# large moves this by a hundred, whatever the index and whatever the sign of
|
||||
# the price.
|
||||
EUR_KWH_PER_EUR_MWH = 0.001
|
||||
|
||||
# The two plausibility bounds for an INJECTION leg. ⚠️ NEITHER LOOKS AT THE
|
||||
# SIGN OF THE PRICE, AND THAT IS THE WHOLE POINT - see
|
||||
# `implausible_injection()`.
|
||||
PASSTHROUGH_LO = 0.10 # 10% of the wholesale price
|
||||
PASSTHROUGH_HI = 10.0 # 1000% of it
|
||||
INJECTION_OFFSET_MAX_EUR_KWH = 0.20
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class _Leg:
|
||||
"""What ONE option's coefficients price, as sentences its refusals read.
|
||||
|
||||
⚠️ TARIFF-16 MADE `option` A PARAMETER RATHER THAN FORKING THE PARSER,
|
||||
exactly as TARIFF-17 made `option`/`means` parameters of
|
||||
`parse_static_profile()` rather than forking the period grammar. A second
|
||||
copy of this parser would be a second `_finite()`, a second unknown-key
|
||||
rule, a second unit table and a second `to_resolution()` - and the two
|
||||
would diverge first on the 23- and 25-hour days, where nobody looks.
|
||||
Everything that differs between the consumption leg and the injection leg
|
||||
is a STRING in this table; the arithmetic, the enumerations, the card
|
||||
comparison and the resolution rule are ONE implementation with one set of
|
||||
checks over it.
|
||||
"""
|
||||
|
||||
option: str
|
||||
what: str # "consumption" / "injection", for a sentence
|
||||
example: str # a VALID blob for this leg, in the JSON-error hint
|
||||
when: str # when this option is read at all
|
||||
flat: str # where a FLAT price of this kind already lives
|
||||
zero_factor: str # what a factor of 0 actually costs on this leg
|
||||
neg_factor: str # why a negative FACTOR is wrong on this leg
|
||||
card_required: bool
|
||||
card_note: str # why it is required, or what is lost without it
|
||||
card_causes: str # the leg-specific tail of `card_refusal()`
|
||||
|
||||
|
||||
_LEGS = {
|
||||
"price_formula": _Leg(
|
||||
option="price_formula",
|
||||
what="consumption",
|
||||
example=('{"index":"epex_be","resolution":"hourly","factor":0.102,'
|
||||
'"offset":1.00,"units":"c_eur_per_kwh","vat_pct":6,'
|
||||
'"card":{"month":"2026-09","index_eur_per_mwh":133.9905,'
|
||||
'"expect_incl_vat":15.55}}'),
|
||||
when="Leave it empty unless price_provider is 'custom_formula'.",
|
||||
zero_factor=("every spread is exactly 0, and arbitrage can never "
|
||||
"clear any threshold - a strategy that silently never "
|
||||
"fires rather than one that is off"),
|
||||
flat=("that is `static_profile` with a single period covering "
|
||||
"00:00-24:00 on all days and price_provider 'off'; the add-on "
|
||||
"then says so at startup instead of leaving you to find out "
|
||||
"from a year of unchanged bills"),
|
||||
neg_factor=("No consumption tariff is indexed negatively; if your "
|
||||
"card shows a minus sign it is on the OFFSET (`A`), "
|
||||
"which is allowed here and common on injection"),
|
||||
card_required=True,
|
||||
card_note=("It is the only thing that can tell a correct pair of "
|
||||
"coefficients from a plausible-looking wrong one"),
|
||||
card_causes=(
|
||||
"or - the expensive one - network charges, levies or excise "
|
||||
"folded into `offset`. ⚠️ THEY DO NOT BELONG THERE: a Belgian "
|
||||
"card's Tariefformule line is the ENERGY component alone (Eneco "
|
||||
"tabulates network tariffs and levies separately; ENGIE says in "
|
||||
"so many words that the formula excludes network, distribution, "
|
||||
"transport, levies and excise), the add-on adds "
|
||||
"price_taxes_eur_kwh on top of it, and folding ~12 c EUR/kWh of "
|
||||
"network charge into `offset` bills you for it twice. That is "
|
||||
"the error this check exists to catch, and it is why it cannot "
|
||||
"be switched off."),
|
||||
),
|
||||
EXPORT_FORMULA_OPTION: _Leg(
|
||||
option=EXPORT_FORMULA_OPTION,
|
||||
what="injection",
|
||||
# ⚠️ NO `card` BLOCK IN THE EXAMPLE, because Eneco's injection line has
|
||||
# none to copy - the formula is printed with no price beside it. An
|
||||
# example carrying one would invite an operator to compute the figure
|
||||
# themselves, which is the one thing this leg must not encourage.
|
||||
example=('{"index":"epex_be","resolution":"hourly","factor":0.1,'
|
||||
'"offset":-1.188,"units":"c_eur_per_kwh","vat_pct":0}'),
|
||||
when=("Leave it empty unless your supplier pays you an injection "
|
||||
"price that moves with the market; a flat one is "
|
||||
"export_price_eur_kwh. ⚠️ This option is read whatever "
|
||||
"price_provider is set to - it is the leg you are PAID on, not "
|
||||
"the one you buy on."),
|
||||
zero_factor=("every hour pays the same, which is a FLAT injection "
|
||||
"price written as a formula. ⚠️ Note this is NOT the "
|
||||
"arbitrage argument the consumption leg gives: no "
|
||||
"strategy in this add-on reads an injection price at "
|
||||
"all, so a flat one here fires nothing and declines "
|
||||
"nothing - it is simply the wrong option"),
|
||||
flat=("that is `export_price_eur_kwh`, the flat injection scalar, "
|
||||
"which is what every site used before this option existed and "
|
||||
"which still answers when this one is empty"),
|
||||
neg_factor=("No Belgian injection tariff is indexed negatively - you "
|
||||
"are paid MORE when the market is dearer, not less. The "
|
||||
"minus sign on an injection card is on the OFFSET (`A`): "
|
||||
"Eneco prints `0,1 x BELPEX-H - 1,188` and Aspiravi "
|
||||
"`0,07 x Belpex - 2`, and a negative offset is accepted "
|
||||
"here"),
|
||||
card_required=False,
|
||||
card_note=(
|
||||
"⚠️ IT IS OPTIONAL ON THIS LEG, AND THAT IS A STATED GAP RATHER "
|
||||
"THAN A RELAXED RULE. A Belgian card prints the CONSUMPTION "
|
||||
"formula with the reference index and the resulting price beside "
|
||||
"it, which is what makes `price_formula`'s self-check possible. "
|
||||
"Eneco's injection line has NO printed price beside it, so on "
|
||||
"that card there is nothing to grade against and requiring a "
|
||||
"`card` block would make the market's own published formula "
|
||||
"inexpressible - or, worse, invite an operator to compute the "
|
||||
"estimate themselves, at which point the check grades the "
|
||||
"coefficients against arithmetic done with the same coefficients. "
|
||||
"Supply it if YOUR card prints one; when it is absent the add-on "
|
||||
"says at startup that this leg is UNGRADED and the two "
|
||||
"coefficient bounds below are all there is"),
|
||||
card_causes=(
|
||||
"or VAT added where there is none. ⚠️ INJECTION IS VAT-EXEMPT IN "
|
||||
"BELGIUM - \"Injectietarieven zijn vrijgesteld van btw\" - while "
|
||||
"consumption is at 6%, so `vat_pct` on THIS option is 0 on every "
|
||||
"Belgian card the research found, and a 6 typed here because it "
|
||||
"is 6 on the consumption leg is a ratio of exactly 1.06. Nothing "
|
||||
"is added to this leg by the framework: price_taxes_eur_kwh is a "
|
||||
"CONSUMPTION component and is not applied to what you are paid "
|
||||
"for export, so an offset carrying network charges is a "
|
||||
"different error here than it is on price_formula and this "
|
||||
"check cannot tell you which one you made."),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FormulaSpec:
|
||||
@@ -199,14 +386,44 @@ class FormulaSpec:
|
||||
offset: float
|
||||
units: str
|
||||
vat_pct: float
|
||||
card_month: str # "YYYY-MM", as the card is dated
|
||||
card_index_eur_per_mwh: float
|
||||
card_expect_incl_vat: float # in `units`, as the card prints it
|
||||
card_month: str = "" # "YYYY-MM", as the card is dated
|
||||
card_index_eur_per_mwh: float = None
|
||||
card_expect_incl_vat: float = None # in `units`, as the card prints it
|
||||
# TARIFF-16. Which OPTION this spec was read from, so a refusal, a log line
|
||||
# and `card_graded` name the leg the operator actually typed.
|
||||
option: str = "price_formula"
|
||||
|
||||
@property
|
||||
def unit_to_eur_kwh(self) -> float:
|
||||
return UNITS[self.units]
|
||||
|
||||
@property
|
||||
def card_graded(self) -> bool:
|
||||
"""Is there a printed estimate to grade these coefficients against?
|
||||
|
||||
⚠️ FALSE IS A REAL, SHIPPED STATE ON THE INJECTION LEG and is reported
|
||||
rather than defaulted: Eneco's injection formula is printed with no
|
||||
price beside it. Never False on `price_formula`, where `_card()`
|
||||
refuses an absent block.
|
||||
"""
|
||||
return self.card_expect_incl_vat is not None
|
||||
|
||||
@property
|
||||
def passthrough(self) -> float:
|
||||
"""The dimensionless share of the wholesale price this passes through.
|
||||
|
||||
`factor x UNITS[units] / 0.001`. 1.00 for Eneco's injection leg, 0.70
|
||||
for Aspiravi's. ⚠️ INDEX-FREE AND SIGN-FREE, which is what lets
|
||||
`implausible_injection()` bound a leg whose price legitimately goes
|
||||
below zero.
|
||||
"""
|
||||
return self.factor * self.unit_to_eur_kwh / EUR_KWH_PER_EUR_MWH
|
||||
|
||||
@property
|
||||
def offset_eur_kwh(self) -> float:
|
||||
"""The offset in EUR/kWh, whatever units the card printed it in."""
|
||||
return self.offset * self.unit_to_eur_kwh
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# The arithmetic. Two functions, and the SECOND one is the contract.
|
||||
@@ -241,7 +458,18 @@ def card_discrepancy(spec: FormulaSpec) -> float:
|
||||
In the card's units, signed: positive means the formula computes MORE than
|
||||
the card prints, which is the direction an `offset` carrying network
|
||||
charges moves it.
|
||||
|
||||
⚠️ RAISES ON A SPEC WITH NO CARD RATHER THAN RETURNING 0.0 (TARIFF-16). An
|
||||
ungraded injection leg has no printed estimate, and a discrepancy of zero
|
||||
is exactly what "the coefficients reproduce the card" looks like - so a
|
||||
silent zero here would report the strongest possible result for the one
|
||||
state in which nothing was compared at all.
|
||||
"""
|
||||
if not spec.card_graded:
|
||||
raise FormulaInvalid(
|
||||
f"{spec.option} has no card block, so there is no printed "
|
||||
f"estimate to measure a discrepancy against. Ask "
|
||||
f"`spec.card_graded` before calling this.")
|
||||
return in_card_units(spec, spec.card_index_eur_per_mwh) \
|
||||
- spec.card_expect_incl_vat
|
||||
|
||||
@@ -250,7 +478,7 @@ def card_discrepancy(spec: FormulaSpec) -> float:
|
||||
# Reading the option
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
def _finite(value, field: str) -> float:
|
||||
def _finite(value, field: str, option: str = "price_formula") -> float:
|
||||
"""A real, finite number - or a refusal naming the field.
|
||||
|
||||
⚠️ SAME CLASS AS `_validate_raw()`'s NaN RULE, one layer earlier. A NaN
|
||||
@@ -260,26 +488,37 @@ def _finite(value, field: str) -> float:
|
||||
"""
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.{field} is {value!r}, which is not a number. "
|
||||
f"{option}.{field} is {value!r}, which is not a number. "
|
||||
f"Write the coefficient as a bare JSON number - 0.102, not "
|
||||
f"\"0.102\" and not an expression: this provider takes FIXED "
|
||||
f"coefficients and evaluates nothing.")
|
||||
if not math.isfinite(float(value)):
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.{field} is {value!r}, which is not finite. A NaN "
|
||||
f"{option}.{field} is {value!r}, which is not finite. A NaN "
|
||||
f"or an infinity here makes every price NaN, every price "
|
||||
f"comparison False, and an arbitrage strategy that never fires "
|
||||
f"while reporting that it is armed.")
|
||||
return float(value)
|
||||
|
||||
|
||||
def _card(raw) -> tuple:
|
||||
"""The `card` block: the estimate the coefficients are graded against."""
|
||||
def _card(raw, leg: _Leg = None) -> tuple:
|
||||
"""The `card` block: the estimate the coefficients are graded against.
|
||||
|
||||
⚠️ REQUIRED ON THE CONSUMPTION LEG AND OPTIONAL ON THE INJECTION ONE, and
|
||||
the asymmetry is a fact about the CARDS rather than a relaxed rule. See
|
||||
`_LEGS[EXPORT_FORMULA_OPTION].card_note`: Eneco's injection formula is
|
||||
printed with no price beside it, so on that card there is nothing to grade
|
||||
against. `("", None, None)` is the ungraded answer and
|
||||
`FormulaSpec.card_graded` is how every caller asks.
|
||||
"""
|
||||
if leg is None:
|
||||
leg = _LEGS["price_formula"]
|
||||
if raw is None:
|
||||
if not leg.card_required:
|
||||
return ("", None, None)
|
||||
raise FormulaInvalid(
|
||||
"price_formula has no \"card\" block, and it is REQUIRED. It is "
|
||||
"the only thing that can tell a correct pair of coefficients from "
|
||||
"a plausible-looking wrong one: the add-on recomputes your "
|
||||
f"{leg.option} has no \"card\" block, and it is REQUIRED. "
|
||||
f"{leg.card_note}: the add-on recomputes your "
|
||||
"supplier's own printed example from the numbers you typed and "
|
||||
"refuses to start if it does not come out. Copy the three figures "
|
||||
"off the same tariff card as the coefficients: "
|
||||
@@ -287,24 +526,26 @@ def _card(raw) -> tuple:
|
||||
"\"expect_incl_vat\": 15.55}.")
|
||||
if not isinstance(raw, dict):
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.card is {type(raw).__name__}, not an object with "
|
||||
f"{leg.option}.card is {type(raw).__name__}, not an object with "
|
||||
f"{', '.join(_CARD_KEYS)}.")
|
||||
unknown = sorted(set(raw) - set(_CARD_KEYS))
|
||||
if unknown:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.card has no field(s) {unknown}. The fields it "
|
||||
f"{leg.option}.card has no field(s) {unknown}. The fields it "
|
||||
f"takes are {list(_CARD_KEYS)}; a key that is merely ignored is a "
|
||||
f"number the operator believes took effect.")
|
||||
month = str(raw.get("month", "") or "").strip()
|
||||
if not _month_date(month):
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.card.month is {raw.get('month')!r}; write the "
|
||||
f"{leg.option}.card.month is {raw.get('month')!r}; write the "
|
||||
f"month the card is dated as \"YYYY-MM\", e.g. \"2026-09\". It is "
|
||||
f"not used in any price - it is what lets the add-on tell you "
|
||||
f"your card has gone stale.")
|
||||
return (month,
|
||||
_finite(raw.get("index_eur_per_mwh"), "card.index_eur_per_mwh"),
|
||||
_finite(raw.get("expect_incl_vat"), "card.expect_incl_vat"))
|
||||
_finite(raw.get("index_eur_per_mwh"), "card.index_eur_per_mwh",
|
||||
leg.option),
|
||||
_finite(raw.get("expect_incl_vat"), "card.expect_incl_vat",
|
||||
leg.option))
|
||||
|
||||
|
||||
def _month_date(month: str):
|
||||
@@ -316,9 +557,16 @@ def _month_date(month: str):
|
||||
return None
|
||||
|
||||
|
||||
def parse_price_formula(value):
|
||||
def parse_price_formula(value, *, option: str = "price_formula"):
|
||||
"""`price_formula` -> a `FormulaSpec`, or None when unset.
|
||||
|
||||
⚠️ `option` IS TARIFF-16'S WHOLE REUSE, and it is TARIFF-17's move. It
|
||||
selects a row of `_LEGS` and nothing else: the enumerations, the
|
||||
arithmetic, `to_resolution()`, the unknown-key rule and the card
|
||||
comparison are shared, and every pre-existing call site - which passes no
|
||||
`option` at all - lands on the consumption row and reads byte-identical
|
||||
sentences. `parse_export_formula()` is a two-line wrapper, not a fork.
|
||||
|
||||
Accepts what the option can actually arrive as, exactly as
|
||||
`parse_static_profile()` does:
|
||||
|
||||
@@ -335,6 +583,7 @@ def parse_price_formula(value):
|
||||
fetch - go through this one function, so there is no route to a price that
|
||||
has not been graded against the card.
|
||||
"""
|
||||
leg = _LEGS[option]
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, str):
|
||||
@@ -345,16 +594,13 @@ def parse_price_formula(value):
|
||||
value = json.loads(text)
|
||||
except ValueError as e:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula is not valid JSON ({e}). It is a JSON object "
|
||||
f"{option} is not valid JSON ({e}). It is a JSON object "
|
||||
f"on one line, e.g.\n"
|
||||
f' {{"index":"epex_be","resolution":"hourly","factor":0.102,'
|
||||
f'"offset":1.00,"units":"c_eur_per_kwh","vat_pct":6,'
|
||||
f'"card":{{"month":"2026-09","index_eur_per_mwh":133.9905,'
|
||||
f'"expect_incl_vat":15.55}}}}\n'
|
||||
f"Leave it empty unless price_provider is 'custom_formula'.")
|
||||
f" {leg.example}\n"
|
||||
f"{leg.when}")
|
||||
if not isinstance(value, dict):
|
||||
raise FormulaInvalid(
|
||||
f"price_formula is {type(value).__name__}, not a JSON object with "
|
||||
f"{option} is {type(value).__name__}, not a JSON object with "
|
||||
f"{', '.join(_TOP_KEYS)}.")
|
||||
|
||||
# ⚠️ AN UNKNOWN KEY IS REFUSED, NOT IGNORED, AND THIS IS THE HALF THAT
|
||||
@@ -366,7 +612,7 @@ def parse_price_formula(value):
|
||||
unknown = sorted(set(value) - set(_TOP_KEYS))
|
||||
if unknown:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula has no field(s) {unknown}. The fields it takes "
|
||||
f"{option} has no field(s) {unknown}. The fields it takes "
|
||||
f"are {list(_TOP_KEYS)}. ⚠️ There is deliberately NO field that "
|
||||
f"takes an expression: this provider multiplies and adds two "
|
||||
f"FIXED coefficients and evaluates nothing, because two "
|
||||
@@ -378,7 +624,7 @@ def parse_price_formula(value):
|
||||
index = str(value.get("index", "") or "").strip()
|
||||
if index not in INDEXES:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.index is {value.get('index')!r}. The reference "
|
||||
f"{option}.index is {value.get('index')!r}. The reference "
|
||||
f"series this add-on can fetch are "
|
||||
f"{', '.join(f'{k!r} ({v})' for k, v in sorted(INDEXES.items()))}. "
|
||||
f"If your card names a different index, the add-on cannot get it "
|
||||
@@ -388,7 +634,7 @@ def parse_price_formula(value):
|
||||
resolution = str(value.get("resolution", "") or "").strip()
|
||||
if resolution not in RESOLUTIONS:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.resolution is {value.get('resolution')!r}; it "
|
||||
f"{option}.resolution is {value.get('resolution')!r}; it "
|
||||
f"must be one of {list(RESOLUTIONS)}. Belgium has been on a "
|
||||
f"15-minute MTU since 2025-10-01 and the feed publishes 96 points "
|
||||
f"a day; a contract written against the HOURLY series is priced "
|
||||
@@ -402,16 +648,16 @@ def parse_price_formula(value):
|
||||
units = str(value.get("units", "") or "").strip()
|
||||
if units not in UNITS:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.units is {value.get('units')!r} and is REQUIRED - "
|
||||
f"{option}.units is {value.get('units')!r} and is REQUIRED - "
|
||||
f"there is no default, on purpose. It must be one of "
|
||||
f"{sorted(UNITS)}. Your card prints the formula in ONE of these "
|
||||
f"and two suppliers use two different conventions for the same "
|
||||
f"shape, so assuming one would be a factor of 100 or 1000 on "
|
||||
f"every hour with nothing able to notice.")
|
||||
|
||||
factor = _finite(value.get("factor"), "factor")
|
||||
offset = _finite(value.get("offset"), "offset")
|
||||
vat_pct = _finite(value.get("vat_pct"), "vat_pct")
|
||||
factor = _finite(value.get("factor"), "factor", option)
|
||||
offset = _finite(value.get("offset"), "offset", option)
|
||||
vat_pct = _finite(value.get("vat_pct"), "vat_pct", option)
|
||||
|
||||
# ⚠️ ZERO IS NOT "NO INDEXATION", IT IS A FIXED TARIFF WEARING A DYNAMIC
|
||||
# ONE'S CLOTHES. Every hour comes out at the same price, so every spread is
|
||||
@@ -421,15 +667,10 @@ def parse_price_formula(value):
|
||||
# the operator at it rather than let them build it by accident.
|
||||
if factor == 0.0:
|
||||
raise FormulaInvalid(
|
||||
"price_formula.factor is 0, so the index would not enter the "
|
||||
f"{option}.factor is 0, so the index would not enter the "
|
||||
"price at all: every hour of every day comes out at "
|
||||
f"{offset:g} x (1 + {vat_pct:g}/100), every spread is exactly 0, "
|
||||
"and arbitrage can never clear any threshold - a strategy that "
|
||||
"silently never fires rather than one that is off. If your tariff "
|
||||
"really is one flat price, that is `static_profile` with a single "
|
||||
"period covering 00:00-24:00 on all days and price_provider "
|
||||
"'off'; the add-on then says so at startup instead of leaving you "
|
||||
"to find out from a year of unchanged bills.")
|
||||
f"{offset:g} x (1 + {vat_pct:g}/100), {leg.zero_factor}. If "
|
||||
f"your {leg.what} tariff really is one flat price, {leg.flat}.")
|
||||
|
||||
# ⚠️ A NEGATIVE FACTOR INVERTS THE MARKET, and the direction is the danger:
|
||||
# the dearest hour becomes the cheapest one, so the battery is told to
|
||||
@@ -437,37 +678,96 @@ def parse_price_formula(value):
|
||||
# mispriced site, it is a site actively trading against itself.
|
||||
if factor < 0.0:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.factor is {factor:g}, which is NEGATIVE. That "
|
||||
f"{option}.factor is {factor:g}, which is NEGATIVE. That "
|
||||
f"inverts the market: the dearest hour of the day comes out as "
|
||||
f"the cheapest one, so the battery would charge at the evening "
|
||||
f"peak and discharge at 03:00 - trading against itself on every "
|
||||
f"cycle. No consumption tariff is indexed negatively; if your "
|
||||
f"card shows a minus sign it is on the OFFSET (`A`), which is "
|
||||
f"allowed here and common on injection.")
|
||||
f"cycle. {leg.neg_factor}.")
|
||||
|
||||
# ⚠️ 0 IS LEGITIMATE AND MUST STAY SO: injection is VAT-exempt in Belgium,
|
||||
# and some cards are already quoted VAT-inclusive. The bound exists for the
|
||||
# 106 / 1.06 / 6 confusion, not to make VAT compulsory.
|
||||
if not 0.0 <= vat_pct <= 30.0:
|
||||
raise FormulaInvalid(
|
||||
f"price_formula.vat_pct is {vat_pct:g} and must be between 0 and "
|
||||
f"{option}.vat_pct is {vat_pct:g} and must be between 0 and "
|
||||
f"30. It is a PERCENTAGE, so Belgian residential electricity is "
|
||||
f"6, not 0.06 and not 106. Zero is legitimate and is not refused: "
|
||||
f"injection is VAT-exempt, and a card that already quotes "
|
||||
f"VAT-inclusive coefficients needs no second multiplication.")
|
||||
|
||||
month, card_index, card_expect = _card(value.get("card"))
|
||||
month, card_index, card_expect = _card(value.get("card"), leg)
|
||||
spec = FormulaSpec(index=index, resolution=resolution, factor=factor,
|
||||
offset=offset, units=units, vat_pct=vat_pct,
|
||||
card_month=month, card_index_eur_per_mwh=card_index,
|
||||
card_expect_incl_vat=card_expect)
|
||||
card_expect_incl_vat=card_expect, option=option)
|
||||
|
||||
delta = card_discrepancy(spec)
|
||||
if abs(delta) > CARD_TOLERANCE:
|
||||
raise FormulaInvalid(card_refusal(spec, delta))
|
||||
# ⚠️ THE CARD SELF-CHECK STILL RUNS WHEREVER THERE IS A CARD TO RUN IT
|
||||
# AGAINST, on either leg, with the same tolerance. What TARIFF-16 adds is
|
||||
# the honest answer for the leg where the card prints no estimate: NOT a
|
||||
# weakened comparison and NOT an estimate computed here, but two bounds on
|
||||
# the COEFFICIENTS that need no printed price - see
|
||||
# `implausible_injection()` - and a startup line saying the leg is
|
||||
# ungraded.
|
||||
if spec.card_graded:
|
||||
delta = card_discrepancy(spec)
|
||||
if abs(delta) > CARD_TOLERANCE:
|
||||
raise FormulaInvalid(card_refusal(spec, delta))
|
||||
if option == EXPORT_FORMULA_OPTION:
|
||||
band = implausible_injection(spec)
|
||||
if band:
|
||||
raise FormulaInvalid(band)
|
||||
return spec
|
||||
|
||||
|
||||
def parse_export_formula(value):
|
||||
"""`price_export_formula` -> the INJECTION leg's `FormulaSpec`, or None.
|
||||
|
||||
TARIFF-16. THE DEFECT THIS EXISTS TO CLOSE: `price.py` modelled injection
|
||||
as ONE scalar, and the market publishes a line with four properties a
|
||||
scalar cannot hold. Verbatim off the cards:
|
||||
|
||||
Eneco Zon & Wind Dynamisch 0,1 x BELPEX-H - 1,188 c EUR/kWh
|
||||
"Het injectietarief is dynamisch en kan per uur wijzigen"
|
||||
- identical on the January and the September 2026 cards
|
||||
ENGIE Dynamic (B x eSpot_15) - A c EUR/kWh
|
||||
Aspiravi (non-dynamic) 0,07 x Belpex - 2
|
||||
|
||||
1. ITS OWN FACTOR. Eneco uses 0,102 on consumption and 0,100 on
|
||||
injection; Aspiravi 0,07 against ~0,10 on its consumption leg. It is
|
||||
NOT the consumption `B` with a sign flip.
|
||||
2. A NEGATIVE OFFSET - `- 1,188`, `- 2`. Note that
|
||||
`price_markup_eur_kwh: float(0,1)` cannot express a negative markup
|
||||
at all, so the offset has no home on the consumption side either.
|
||||
3. VAT-EXEMPT. "Injectietarieven zijn vrijgesteld van btw", while
|
||||
consumption is at 6% - a SIX PERCENT ASYMMETRY between the buy leg
|
||||
and the sell leg, which a single scalar cannot even state.
|
||||
4. IT GOES NEGATIVE, WITH NO FLOOR. Eneco's injection price is negative
|
||||
for any BELPEX-H below 11,88 EUR/MWh, and a PV household exports
|
||||
precisely in the hours most likely to be negative. You can be charged
|
||||
to export.
|
||||
|
||||
⚠️ AND WHAT THIS DOES **NOT** AFFECT TODAY, SAID HERE SO NOBODY READS THE
|
||||
ABOVE AS A TRADING BUG. `arbitrage.py` does not read
|
||||
`export_price_eur_kwh` at all - its own comment says so, and gives §9.3's
|
||||
near-zero Belgian injection price as the reason the economically sound
|
||||
trade on this market is charge-cheap-to-displace-expensive-IMPORT. Both
|
||||
hours it compares are all-in CONSUMPTION prices. So no trade the add-on
|
||||
takes today is decided by this number, and this card is not a correction
|
||||
of a wrong trade. What it changes is what an operator is told, and what
|
||||
any future export-aware strategy would rest on: OPT-06 and any export
|
||||
logic would otherwise inherit a scalar that cannot represent the market,
|
||||
and the 6% VAT asymmetry would be invisible in the arithmetic.
|
||||
|
||||
⚠️ THE SCALAR IS NOT REPLACED. `export_price_eur_kwh()` is untouched and
|
||||
still answers for every site with a flat injection price, which is every
|
||||
site that exists today; this option ships "". That is `price.py`'s own
|
||||
prediction coming true rather than a new design - "when it does land, an
|
||||
injection curve gets a `PriceProvider` of its own and this scalar becomes
|
||||
its FIXED-product default; the seam is already the right shape for that."
|
||||
"""
|
||||
return parse_price_formula(value, option=EXPORT_FORMULA_OPTION)
|
||||
|
||||
|
||||
def card_refusal(spec: FormulaSpec, delta: float) -> str:
|
||||
"""The sentence an operator reads when their formula misses its own card.
|
||||
|
||||
@@ -479,8 +779,9 @@ def card_refusal(spec: FormulaSpec, delta: float) -> str:
|
||||
got = in_card_units(spec, spec.card_index_eur_per_mwh)
|
||||
ratio = (got / spec.card_expect_incl_vat
|
||||
if spec.card_expect_incl_vat else float("inf"))
|
||||
leg = _LEGS[spec.option]
|
||||
return (
|
||||
f"price_formula does not reproduce its own card, so the add-on will "
|
||||
f"{spec.option} does not reproduce its own card, so the add-on will "
|
||||
f"NOT start on it. Your contract's arithmetic is "
|
||||
f"price = (factor x index_eur_per_mwh + offset) x (1 + vat_pct/100); "
|
||||
f"on the card's own index that is "
|
||||
@@ -496,15 +797,7 @@ def card_refusal(spec: FormulaSpec, delta: float) -> str:
|
||||
f"1000 - `units` must be the one the formula line is printed in); VAT "
|
||||
f"left out or applied twice (ratio 1.06 or 1/1.06); a transposed "
|
||||
f"digit; the two sides copied off DIFFERENT cards or different "
|
||||
f"months; or - the expensive one - network charges, levies or excise "
|
||||
f"folded into `offset`. ⚠️ THEY DO NOT BELONG THERE: a Belgian card's "
|
||||
f"Tariefformule line is the ENERGY component alone (Eneco tabulates "
|
||||
f"network tariffs and levies separately; ENGIE says in so many words "
|
||||
f"that the formula excludes network, distribution, transport, levies "
|
||||
f"and excise), the add-on adds price_taxes_eur_kwh on top of it, and "
|
||||
f"folding ~12 c EUR/kWh of network charge into `offset` bills you for "
|
||||
f"it twice. That is the error this check exists to catch, and it is "
|
||||
f"why it cannot be switched off.")
|
||||
f"months; {leg.card_causes}")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -520,13 +813,16 @@ def implausible_all_in(spec: FormulaSpec, taxes_eur_kwh: float):
|
||||
|
||||
⚠️ THE LOW END IS GRADED ON THE ENERGY COMPONENT AND THE HIGH END ON THE
|
||||
ALL-IN FIGURE, AND THAT ASYMMETRY IS THE CHECK RATHER THAN AN OVERSIGHT.
|
||||
`price_taxes_eur_kwh` ships at 0.06, which is three times the low bound -
|
||||
so a card read a HUNDRED times too small comes out at 0.0016 EUR/kWh of
|
||||
energy, is carried over the floor by the flat tax addend alone, and passes
|
||||
a band applied to the all-in total. The hundredfold error is precisely
|
||||
what this exists to catch, so the floor is applied where it can still see
|
||||
it. The ceiling is applied to the all-in figure because that is the number
|
||||
the site is really billed at, and taxes only push it up.
|
||||
`price_taxes_eur_kwh` ships at 0.11736 (TARIFF-18; it was 0.06 before, and
|
||||
the argument was already decisive at that figure), which is nearly SIX
|
||||
times the low bound - so a card read a HUNDRED times too small comes out at
|
||||
0.0016 EUR/kWh of energy, is carried over the floor by the flat tax addend
|
||||
alone, and passes a band applied to the all-in total. The hundredfold error
|
||||
is precisely what this exists to catch, so the floor is applied where it
|
||||
can still see it. ⚠️ Raising the default made this trap WIDER, not
|
||||
narrower: the addend that does the carrying got bigger. The ceiling is
|
||||
applied to the all-in figure because that is the number the site is really
|
||||
billed at, and taxes only push it up.
|
||||
|
||||
⚠️ AND THE LIMIT, WITH THE CLAIM. This grades the CARD'S OWN POINT - one
|
||||
price, at the monthly index the card assumed - and not every hour of every
|
||||
@@ -536,13 +832,27 @@ def implausible_all_in(spec: FormulaSpec, taxes_eur_kwh: float):
|
||||
fetched series. What it catches is a formula whose whole LEVEL is wrong,
|
||||
which is the factor-of-1000 class arriving from the end
|
||||
`MAX_PLAUSIBLE_EUR_KWH` does not bound.
|
||||
|
||||
⚠️ AND IT IS THE CONSUMPTION LEG'S BAND ONLY - TARIFF-16 DELIBERATELY DID
|
||||
NOT POINT IT AT THE INJECTION LEG. Two reasons, and the second is an
|
||||
acceptance criterion rather than a preference:
|
||||
|
||||
* it adds `taxes_eur_kwh`, and `price_taxes_eur_kwh` is a CONSUMPTION
|
||||
component. Nothing is added to what a site is PAID for export, so the
|
||||
`all_in` half would be adding a number the injection leg never carries;
|
||||
* its floor is `energy >= 0.02 EUR/kWh`, and a REAL Eneco injection price
|
||||
is negative for any BELPEX-H below 11,88 EUR/MWh - the hours a PV
|
||||
household actually exports in. Applied to injection this floor would
|
||||
refuse the market, and refuse it hardest in the hours where knowing the
|
||||
number matters most. `implausible_injection()` is the injection band
|
||||
and it is deliberately NOT this function with a lower floor.
|
||||
"""
|
||||
energy = price_eur_kwh(spec, spec.card_index_eur_per_mwh)
|
||||
all_in = energy + float(taxes_eur_kwh)
|
||||
if energy >= PLAUSIBLE_LO_EUR_KWH and all_in <= PLAUSIBLE_HI_EUR_KWH:
|
||||
return None
|
||||
return (
|
||||
f"price_formula's own card works out at {energy:.5f} EUR/kWh of "
|
||||
f"{spec.option}'s own card works out at {energy:.5f} EUR/kWh of "
|
||||
f"energy ({spec.card_expect_incl_vat:g} {spec.units} as the card "
|
||||
f"prints it) and {all_in:.5f} EUR/kWh all-in once "
|
||||
f"price_taxes_eur_kwh is added, which is outside the plausible band "
|
||||
@@ -558,6 +868,85 @@ def implausible_all_in(spec: FormulaSpec, taxes_eur_kwh: float):
|
||||
f"the best charging opportunity of the year - is never refused.")
|
||||
|
||||
|
||||
def implausible_injection(spec: FormulaSpec):
|
||||
"""The INJECTION leg's plausibility band. Returns a refusal or None.
|
||||
|
||||
⚠️ A NEGATIVE INJECTION PRICE IS ACCEPTED, NOT REFUSED, AND NEITHER RUNG
|
||||
BELOW LOOKS AT THE SIGN OR THE LEVEL OF A PRICE. Eneco's published line
|
||||
`0,1 x BELPEX-H - 1,188` is negative for any BELPEX-H under 11,88 EUR/MWh;
|
||||
those are the midday hours a PV household exports in, so a band with a
|
||||
floor above zero - which is what `implausible_all_in()` has, for the
|
||||
consumption leg's own good reasons - would refuse the real market and
|
||||
would hide it in exactly the hours it costs money. You CAN be charged to
|
||||
export. The add-on says so rather than declining to represent it.
|
||||
|
||||
THE PROBLEM THAT LEAVES, STATED BEFORE THE SOLUTION. The consumption
|
||||
floor was not decoration: it is what catches a whole card read a hundred
|
||||
times too small, the one unit error the card self-check cannot see because
|
||||
it cancels out of a comparison between the two sides. A band that spans
|
||||
zero cannot catch it - 0.00132 EUR/kWh is inside any interval that
|
||||
contains -0.03. So the bound moves OFF the price and ONTO the
|
||||
coefficients, where it is index-free and sign-free:
|
||||
|
||||
* PASS-THROUGH. `factor x UNITS[units] / 0.001` is the dimensionless
|
||||
share of the wholesale price the contract passes through, because one
|
||||
EUR/MWh IS 0.001 EUR/kWh. Eneco's injection leg is 1.00 and Aspiravi's
|
||||
is 0.70. A factor typed 100x too small reads 0.01 and 100x too large
|
||||
reads 100, whatever the index and whatever the sign of the result.
|
||||
* OFFSET MAGNITUDE. Eneco's is 1,188 c EUR/kWh = 0.01188 EUR/kWh and
|
||||
Aspiravi's is 2 c = 0.02. A hundredfold error is 1.188 EUR/kWh, which
|
||||
is not an injection tariff in any direction. The bound is on the
|
||||
ABSOLUTE value, so a negative offset of a believable size passes and
|
||||
that is the normal case on this leg.
|
||||
|
||||
⚠️ TWO RUNGS THAT CAN BOTH ANSWER ONE STIMULUS, SO THEY ARE GRADED ON
|
||||
THEIR REASONS AND MUTATED TOGETHER (MUTATION.md, TEST-16). A whole card
|
||||
read 100x too large trips both. The fixtures in test_price.py 17d are
|
||||
built so that each rung is the ONLY one that fires on its own stimulus.
|
||||
|
||||
⚠️ AND WHAT THIS CANNOT SEE, WITH THE CLAIM (habit 13). It bounds the
|
||||
SHAPE of the coefficients, never their truth: a contract really written
|
||||
against a different index, or last year's coefficients, passes both rungs
|
||||
and reproduces any card typed beside them. Where a card DOES print an
|
||||
estimate the self-check grades the pair against it; where it does not -
|
||||
which is Eneco's injection line - these two bounds are the whole of what
|
||||
is mechanised, and validate.py says so at startup.
|
||||
"""
|
||||
if not PASSTHROUGH_LO <= spec.passthrough <= PASSTHROUGH_HI:
|
||||
return (
|
||||
f"{spec.option}.factor is {spec.factor:g} {spec.units} per "
|
||||
f"EUR/MWh, which passes through {spec.passthrough:.4g}x the "
|
||||
f"wholesale price - outside the plausible "
|
||||
f"{PASSTHROUGH_LO}-{PASSTHROUGH_HI}x for an injection tariff. A "
|
||||
f"Belgian injection formula pays a share of the market price a "
|
||||
f"little under or about equal to it: Eneco's "
|
||||
f"`0,1 x BELPEX-H - 1,188` c EUR/kWh is 1.00x and Aspiravi's "
|
||||
f"`0,07 x Belpex - 2` is 0.70x. {spec.passthrough:.4g}x is what a "
|
||||
f"factor typed in the wrong units looks like - check `units` "
|
||||
f"({spec.units!r}) against the unit printed beside your formula, "
|
||||
f"because the card self-check cannot see a factor of 10, 100 or "
|
||||
f"1000 applied to BOTH sides at once. ⚠️ This bounds the "
|
||||
f"COEFFICIENT and not the price: an injection price below zero is "
|
||||
f"accepted and is the real market - Eneco's goes negative under "
|
||||
f"11.88 EUR/MWh of BELPEX-H, which is the middle of a sunny day.")
|
||||
if abs(spec.offset_eur_kwh) > INJECTION_OFFSET_MAX_EUR_KWH:
|
||||
return (
|
||||
f"{spec.option}.offset is {spec.offset:g} {spec.units} = "
|
||||
f"{spec.offset_eur_kwh:+.5f} EUR/kWh, and |offset| above "
|
||||
f"{INJECTION_OFFSET_MAX_EUR_KWH} EUR/kWh is not a Belgian "
|
||||
f"injection tariff in either direction. The published ones are "
|
||||
f"small and NEGATIVE - Eneco -1,188 c EUR/kWh (-0.01188), "
|
||||
f"Aspiravi -2 c (-0.02) - so a minus sign here is expected and is "
|
||||
f"not what this refuses; a MAGNITUDE two orders out is. The usual "
|
||||
f"cause is the offset typed in a different unit from `units` "
|
||||
f"({spec.units!r}), or a consumption offset copied onto the "
|
||||
f"injection leg: they are different numbers on the same card. "
|
||||
f"⚠️ Network charges and levies do not belong here either - "
|
||||
f"nothing is added to what you are PAID for export, so an offset "
|
||||
f"carrying them is simply wrong rather than double-counted.")
|
||||
return None
|
||||
|
||||
|
||||
def stale_card(spec: FormulaSpec, today=None):
|
||||
"""A warning when the card is older than ~6 months, or None. NEVER a
|
||||
refusal: ENGIE freezes a contract's coefficients for its duration, so an
|
||||
@@ -568,7 +957,7 @@ def stale_card(spec: FormulaSpec, today=None):
|
||||
if dated is None or (now - dated).days <= CARD_STALE_DAYS:
|
||||
return None
|
||||
return (
|
||||
f"price_formula's card is dated {spec.card_month}, which is "
|
||||
f"{spec.option}'s card is dated {spec.card_month}, which is "
|
||||
f"{(now - dated).days} days ago. Suppliers reprice: if your contract "
|
||||
f"has been renewed or rolled over since then, the coefficients here "
|
||||
f"are last year's and every price this add-on computes is wrong by "
|
||||
|
||||
+158
-18
@@ -151,8 +151,8 @@ from textwrap import dedent
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from .custom_formula import (
|
||||
FormulaInvalid, PREVIEW_HOURS, parse_price_formula, preview_lines,
|
||||
price_eur_kwh, to_resolution)
|
||||
EXPORT_FORMULA_OPTION, FormulaInvalid, PREVIEW_HOURS, parse_export_formula,
|
||||
parse_price_formula, preview_lines, price_eur_kwh, to_resolution)
|
||||
|
||||
_LOG = logging.getLogger("goodwe.price")
|
||||
|
||||
@@ -818,6 +818,69 @@ def plan_is_provisional(read: PriceRead) -> bool:
|
||||
# Options: what a plugin may see, and what it may not
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# TARIFF-18: what `price_taxes_eur_kwh` IS MADE OF
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
# ⚠️ THE DEFECT THIS TABLE PREVENTS IS THE ONE THE SHIPPED 0.06 WAS: A NUMBER
|
||||
# NOBODY COULD SOURCE. 0.06 EUR/kWh is roughly HALF the real Flemish non-energy
|
||||
# figure, and because no reader could see what it was made of there was nothing
|
||||
# to argue with. Every row below is one line of the Eneco residential card for
|
||||
# Flanders, September 2026, INCLUDING 6 % VAT, converted from the c EUR/kWh the
|
||||
# card prints to the EUR/kWh this option takes. `price_taxes_eur_kwh`'s default
|
||||
# is their sum, and test_price.py section 1b re-adds them and refuses a default
|
||||
# that is not exactly that.
|
||||
#
|
||||
# ⚠️ THIS IS A PER-DSO FIGURE, AND IT IS THE DISTRIBUTION ROW THAT MOVES. Across
|
||||
# the eight Fluvius DSOs that row runs 5,28 c EUR/kWh (Midden-Vlaanderen) to
|
||||
# 6,70 (West), so the all-in Flemish total runs about 0.117 to 0.131 EUR/kWh.
|
||||
# A site outside Antwerpen should type its own total; the other two rows are
|
||||
# Flanders-wide and do not move with the DSO.
|
||||
#
|
||||
# ⚠️ AND THE DEFAULT SITS NEAR THE LOW END OF THAT BAND ON PURPOSE, BECAUSE THE
|
||||
# TWO ERROR DIRECTIONS ARE NOT SYMMETRIC. This scalar is a LEVEL component: it
|
||||
# cancels exactly in `max - min` and cannot move which hour is cheapest
|
||||
# (test_price.py 16b measures that as a family). The one DECISION it reaches is
|
||||
# §17's negative-price guard in arbitrage.py, which tests the ABSOLUTE all-in
|
||||
# price of the sell hour. A figure set too HIGH carries a genuinely negative
|
||||
# hour up above zero, and the add-on exports into paid-for disposal - the exact
|
||||
# case §17 exists to refuse. A figure set too LOW only declines a trade that
|
||||
# would have paid. So where a default must stand in for eight different DSOs,
|
||||
# it belongs at the bottom of the band and not in the middle of it.
|
||||
#
|
||||
# ⚠️ `energiebijdrage` IS ZERO, AND IT IS A ROW HERE RATHER THAN AN ABSENCE.
|
||||
# "Vanaf 1 augustus 2026 bedraagt de energiebijdrage 0 EUR/MWh" - it was merged
|
||||
# into the bijzondere accijns. Anyone re-deriving this total from a guide
|
||||
# written before that date will find a separate energiebijdrage line and add it
|
||||
# on top of an accijns that already contains it. The zero row is here so that
|
||||
# the double-count is visible as a decision rather than as an omission.
|
||||
FLEMISH_TAXES_COMPONENTS_EUR_KWH = (
|
||||
("Fluvius distribution, Antwerpen", 0.0535),
|
||||
("Bijzondere accijns, 'Alle verbruik' - no volume bands", 0.04876),
|
||||
("Bijdrage groene stroom en WKK Vlaanderen", 0.0151),
|
||||
("Energiebijdrage - 0 EUR/MWh since 2026-08-01, inside the accijns", 0.0),
|
||||
)
|
||||
|
||||
# ⚠️ TARIFF-18, AND IT IS NOT HOUSEKEEPING - IT DECIDES WHICH CONFIGS START.
|
||||
# TARIFF-17's rung in validate.py refuses a site that sets `price_taxes_profile`
|
||||
# AND leaves `price_taxes_eur_kwh` at something other than the shipped default,
|
||||
# because the table wins and the scalar would decide nothing. It compares
|
||||
# against the DEFAULT rather than against presence, because the Supervisor sets
|
||||
# `App.options = deepmerge(config.yaml defaults, stored options)` and a saved
|
||||
# blob therefore carries every schema key whether the operator typed it or not
|
||||
# (measured: the reference install's export is 70 of 71 keys - CHANGELOG 0.9.0,
|
||||
# `tools/supervisor_selfapi_probe.py` §D).
|
||||
#
|
||||
# So moving the default turns a previously ACCEPTED configuration into
|
||||
# `SystemExit(78)`. A site that stored 0.06 - which is every install that has
|
||||
# ever saved its configuration - and that also carries a taxes table would stop
|
||||
# starting on the upgrade, over a number it never typed and that decides
|
||||
# nothing. That refusal would be TRUE and USELESS: the rung's subject is a
|
||||
# number the OPERATOR typed, and a superseded shipped default is not one. It
|
||||
# still reads as "untouched" here, and the rung's sentence names both figures.
|
||||
SUPERSEDED_TAXES_DEFAULTS_EUR_KWH = (0.06,) # TARIFF-02 .. TARIFF-17
|
||||
|
||||
|
||||
# ⚠️ CFG-03, AND HOW THIS TICKET AVOIDS WIDENING IT. Option defaults in this
|
||||
# add-on already live in three places - config.yaml, main.py's `o.get(k, X)`
|
||||
# fallbacks, and a dataclass default - held apart only by a tripwire in
|
||||
@@ -836,7 +899,9 @@ def plan_is_provisional(read: PriceRead) -> bool:
|
||||
PRICE_OPTION_DEFAULTS = {
|
||||
"price_provider": "off",
|
||||
"price_markup_eur_kwh": 0.03, # §14 tariffs.energy_price.markup_eur_kwh
|
||||
"price_taxes_eur_kwh": 0.06, # §14 tariffs.energy_price.taxes_eur_kwh
|
||||
# TARIFF-18: the sum of FLEMISH_TAXES_COMPONENTS_EUR_KWH above, to the
|
||||
# card's own last digit. §14 tariffs.energy_price.taxes_eur_kwh.
|
||||
"price_taxes_eur_kwh": 0.11736,
|
||||
"export_price_eur_kwh": 0.04, # §14 tariffs.export_price_eur_kwh (AC4)
|
||||
"price_csv_path": "/share/goodwe_prices.csv",
|
||||
"price_feed_url": "",
|
||||
@@ -870,6 +935,20 @@ PRICE_OPTION_DEFAULTS = {
|
||||
# `static_profile` precedent exactly, and here for the same CFG-03 reason:
|
||||
# this dict is the ONE in-code mirror of config.yaml.
|
||||
"price_formula": "",
|
||||
# TARIFF-16. The INJECTION leg, in `price_formula`'s OWN grammar and read
|
||||
# by `custom_formula.parse_export_formula()` - the same parser with its
|
||||
# option name as an argument, so a second unit table and a second unknown-
|
||||
# key rule do not exist to diverge. "" is unset and the scalar
|
||||
# `export_price_eur_kwh` above decides, which is every site today.
|
||||
#
|
||||
# ⚠️ IT IS IN FRAMEWORK_KEYS, for the reason the scalar is: a CONSUMPTION
|
||||
# plugin that could read an injection curve could fold it into a
|
||||
# consumption price, and nothing downstream could tell.
|
||||
#
|
||||
# ⚠️ AND IT LIVES HERE RATHER THAN IN custom_formula.py FOR CFG-03's SAKE,
|
||||
# exactly as `price_formula` and `price_taxes_profile` do: this dict is the
|
||||
# ONE in-code mirror of config.yaml.
|
||||
"price_export_formula": "",
|
||||
# OPT-04. §10.1 priority 3, and §14's `optimizer.cycle_cost_threshold_eur`.
|
||||
#
|
||||
# ⚠️ THEY LIVE HERE FOR CFG-03's SAKE, exactly as `static_profile` does, and
|
||||
@@ -902,6 +981,13 @@ FRAMEWORK_KEYS = frozenset({
|
||||
# derived from this set, so `code_leaks()` refuses a plugin that names it
|
||||
# without anything else being edited.
|
||||
"price_taxes_profile",
|
||||
# TARIFF-16. The hour-varying spelling of `export_price_eur_kwh`, and it
|
||||
# belongs here for the same reason the scalar does: a plugin that could
|
||||
# read an INJECTION curve could fold it into the CONSUMPTION series it
|
||||
# emits, and `assemble()` has no way to notice a component that arrived
|
||||
# inside a RawPoint. `BANNED_IN_PLUGIN_CODE` is derived from this set, so
|
||||
# `code_leaks()` refuses a plugin that names it with nothing else edited.
|
||||
EXPORT_FORMULA_OPTION,
|
||||
})
|
||||
|
||||
|
||||
@@ -1015,28 +1101,82 @@ def export_price_eur_kwh(opts: dict) -> float:
|
||||
consumption is at 6% - so it is a second per-contract formula, not a second
|
||||
copy of the first.
|
||||
|
||||
⚠️ TARIFF-15 LANDED THE EVALUATOR AND DID NOT LAND THIS CURVE, and the
|
||||
difference is the point rather than an omission. `custom_formula` can now
|
||||
express `B x index + A` exactly - it is what it exists for - but it is a
|
||||
CONSUMPTION provider: it declares {ENERGY, MARKUP}, the framework adds the
|
||||
consumption taxes, and an injection leg carries its OWN coefficients
|
||||
(Eneco: 0,102 consumption against 0,100 injection) and its own VAT
|
||||
treatment (injection is exempt; consumption is at 6%). Pointing this
|
||||
scalar at that machinery would mean pricing an injection curve with a
|
||||
consumption card, which is the wrong-card defect the card self-check
|
||||
exists to refuse. So until the injection card lands this scalar remains a
|
||||
SIMPLIFICATION an operator enters by hand - an average of what they are
|
||||
actually paid - and not a reflection of the market. When it does land, an
|
||||
injection curve gets a `PriceProvider` of its own and this scalar becomes
|
||||
its FIXED-product default; the seam is already the right shape for that.
|
||||
⚠️ TARIFF-16 LANDED THE INJECTION LEG, AND THIS FUNCTION IS UNCHANGED. The
|
||||
curve lives in `price_export_formula` and is read by `export_formula()`
|
||||
below; this reader still answers the FLAT injection price, still from one
|
||||
option, still with no formula anywhere in its arithmetic. That is the
|
||||
arrangement this docstring predicted before either existed - "an injection
|
||||
curve gets a `PriceProvider` of its own and this scalar becomes its
|
||||
FIXED-product default" - and it is why a site with a flat injection price
|
||||
sees nothing change: `price_export_formula` ships "", `export_price_at()`
|
||||
falls through to this function, and this function's body is byte-identical
|
||||
to the one TARIFF-02 shipped.
|
||||
|
||||
⚠️ It is NOT reachable from a plugin: `export_price_eur_kwh` is in
|
||||
FRAMEWORK_KEYS, so a consumption plugin cannot quietly fold an injection
|
||||
price into a consumption price.
|
||||
price into a consumption price. `price_export_formula` is in the same set
|
||||
for the same reason.
|
||||
|
||||
⚠️ AND NOTHING IN THIS ADD-ON READS EITHER ONE TO TAKE A DECISION.
|
||||
`arbitrage.py` prices the sell side as DISPLACED IMPORT and says so in its
|
||||
own comment; both hours it compares are all-in consumption prices. This
|
||||
reader has no caller under `app/` and neither does `export_price_at()`.
|
||||
They are what an operator is shown and what a future export-aware strategy
|
||||
would call - not a number any trade turns on today.
|
||||
"""
|
||||
return float(price_option(opts, "export_price_eur_kwh"))
|
||||
|
||||
|
||||
def export_formula(opts: dict):
|
||||
"""The configured `price_export_formula` as a `FormulaSpec`, or None.
|
||||
|
||||
TARIFF-16. Raises `custom_formula.FormulaInvalid` on a malformed leg - and
|
||||
⚠️ THAT EXCEPTION IS NOT MEANT TO REACH A RUNNING SITE, by the rule
|
||||
`taxes_profile()` states above and `static_profile` established:
|
||||
validate.py parses the same option at STARTUP and refuses to start on it,
|
||||
because a formula that only fails when something reads it is a defect
|
||||
discovered at the worst possible moment and §11.4 makes every price
|
||||
defect quiet.
|
||||
|
||||
⚠️ THE PARSE IS THE SAME ONE THE CONSUMPTION LEG GETS. There is no second
|
||||
parser, no second unit table and no second resolution rule -
|
||||
`parse_export_formula()` is `parse_price_formula()` with its `option`
|
||||
argument moved, so every refusal an operator can hit on this leg is a
|
||||
refusal that already had checks over it.
|
||||
"""
|
||||
return parse_export_formula(price_option(opts, EXPORT_FORMULA_OPTION))
|
||||
|
||||
|
||||
def export_price_at(opts: dict, index_eur_per_mwh: float) -> float:
|
||||
"""What the site is PAID for one exported kWh at one index value, EUR/kWh.
|
||||
|
||||
THE SEAM, AND ITS HONEST SCOPE. This is the one function a future
|
||||
export-aware strategy calls, and it has NO CALLER UNDER `app/` today -
|
||||
stated here rather than implied, because the add-on takes no decision on an
|
||||
injection price (see `export_price_eur_kwh()` above and `arbitrage.py`'s
|
||||
accounting-basis comment). What it buys now is that OPT-06 and anything
|
||||
after it inherit a shape the market fits, instead of a scalar that cannot
|
||||
hold its own factor, a negative offset, or a VAT rate different from the
|
||||
consumption leg's.
|
||||
|
||||
⚠️ THE FLAT PATH IS THE FALLTHROUGH AND IT IGNORES THE INDEX, which is
|
||||
CORRECT rather than a simplification: a site with a flat injection price is
|
||||
paid the same for every kWh whatever the market did, and that is what the
|
||||
scalar means. With `price_export_formula` empty - every site today - this
|
||||
returns exactly `export_price_eur_kwh(opts)` for every index.
|
||||
|
||||
⚠️ A NEGATIVE ANSWER IS A REAL ANSWER. Eneco's `0,1 x BELPEX-H - 1,188` is
|
||||
below zero for any BELPEX-H under 11,88 EUR/MWh, which is the middle of a
|
||||
sunny day and precisely when a PV household exports. Nothing here floors
|
||||
it: a caller that silently clamped it to zero would hide the hours in which
|
||||
exporting COSTS money, which is the one thing an injection price is for.
|
||||
"""
|
||||
spec = export_formula(opts)
|
||||
if spec is None:
|
||||
return export_price_eur_kwh(opts)
|
||||
return price_eur_kwh(spec, index_eur_per_mwh)
|
||||
|
||||
|
||||
def taxes_profile(opts: dict):
|
||||
"""The configured `price_taxes_profile` as a period table, or None.
|
||||
|
||||
|
||||
@@ -325,12 +325,15 @@ import logging
|
||||
from .arbitrage import enabled as arbitrage_on
|
||||
from .control import SLEW_RAIL_FRAC, LOOP_TICK_S, PLANT_SETTLE_S
|
||||
from .custom_formula import (
|
||||
FormulaInvalid, implausible_all_in, parse_price_formula, stale_card)
|
||||
EXPORT_FORMULA_OPTION, FormulaInvalid, implausible_all_in,
|
||||
parse_export_formula, parse_price_formula, stale_card)
|
||||
from .inverter import roster_entries
|
||||
from .maintenance import MAINT_OPTION_DEFAULTS
|
||||
from .p1 import is_enabled, validate_meter_options
|
||||
from .peakguard import PEAK_OPTION_DEFAULTS
|
||||
from .price import PRICE_OPTION_DEFAULTS, PROVIDERS, RETIRED_PROVIDERS
|
||||
from .price import (
|
||||
PRICE_OPTION_DEFAULTS, PROVIDERS, RETIRED_PROVIDERS,
|
||||
SUPERSEDED_TAXES_DEFAULTS_EUR_KWH)
|
||||
from .static_tariff import (
|
||||
ProfileInvalid, TAXES_PROFILE_OPTION, parse_static_profile,
|
||||
parse_taxes_profile)
|
||||
@@ -1444,13 +1447,32 @@ def _price_problems(opts: dict) -> list[str]:
|
||||
# the price-entity/static_profile pair above. The table decides when it
|
||||
# is set, so a non-default scalar left beside it is a number the
|
||||
# operator typed that changes nothing, on the quantity §11.4 makes
|
||||
# hardest to notice. It is compared against the SHIPPED DEFAULT rather
|
||||
# hardest to notice. It is compared against the SHIPPED DEFAULTS rather
|
||||
# than against presence, because the Supervisor writes every schema key
|
||||
# into the options file whether the operator touched it or not.
|
||||
# into the options file whether the operator touched it or not - so
|
||||
# "the operator did not type this" has to be read off the VALUE.
|
||||
#
|
||||
# ⚠️ TARIFF-18: "UNTOUCHED" IS A SET, NOT ONE NUMBER, AND THE DEFECT
|
||||
# THAT MAKES IT ONE IS AN UPGRADE THAT STOPS A BATTERY CONTROLLER
|
||||
# STARTING. The Supervisor sets `App.options = deepmerge(config.yaml
|
||||
# defaults, stored options)`, so a saved blob carries every schema key
|
||||
# whether the operator typed it or not - the reference install's export
|
||||
# is 70 of 71. When TARIFF-18 moved this default 0.06 -> 0.11736, every
|
||||
# such blob went from "equal to the shipped default" to "not equal to
|
||||
# it" without anybody editing anything, and a site that also carries a
|
||||
# taxes table would have met `SystemExit(78)` on the upgrade. The
|
||||
# sentence below is about a number the OPERATOR TYPED; a superseded
|
||||
# shipped default is not one, so it still reads as untouched. The set
|
||||
# is in price.py beside the default it supersedes, because the two only
|
||||
# ever move together.
|
||||
scalar = _number(opts, "price_taxes_eur_kwh",
|
||||
PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"])
|
||||
shipped = PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"]
|
||||
if scalar is not None and abs(scalar - shipped) > 1e-12:
|
||||
untouched = (shipped,) + tuple(SUPERSEDED_TAXES_DEFAULTS_EUR_KWH)
|
||||
superseded = ", ".join(
|
||||
str(u) for u in SUPERSEDED_TAXES_DEFAULTS_EUR_KWH)
|
||||
if scalar is not None \
|
||||
and not any(abs(scalar - u) <= 1e-12 for u in untouched):
|
||||
problems.append(
|
||||
f"{TAXES_PROFILE_OPTION} is set AND price_taxes_eur_kwh is "
|
||||
f"{scalar} rather than its shipped {shipped}. THE TABLE WINS: "
|
||||
@@ -1458,7 +1480,10 @@ def _price_problems(opts: dict) -> list[str]:
|
||||
f"the scalar, so the number you typed there would decide "
|
||||
f"nothing and nothing would say so. Set price_taxes_eur_kwh "
|
||||
f"back to {shipped}, or clear {TAXES_PROFILE_OPTION} to keep "
|
||||
f"the flat figure.")
|
||||
f"the flat figure. (A scalar still sitting on a SUPERSEDED "
|
||||
f"default - {superseded} - is accepted and NOT refused: "
|
||||
f"that is a number this add-on wrote into your options "
|
||||
f"blob, not one you typed.)")
|
||||
|
||||
# ⚠️ THE UNITS RUNG, AND IT IS A SECOND QUANTITY RATHER THAN A
|
||||
# RESTATEMENT. Every Belgian DSO prints these bands in c EUR/kWh
|
||||
@@ -1523,6 +1548,7 @@ def _price_problems(opts: dict) -> list[str]:
|
||||
# CARD AGAINST REALITY. A consistent-but-wrong pair - both numbers off the
|
||||
# wrong product - reproduces its own printed price and passes. Nothing can
|
||||
# catch that.
|
||||
spec = None # TARIFF-16 reads this back, below
|
||||
raw_formula = opts.get("price_formula", "")
|
||||
has_formula = bool(str(raw_formula or "").strip()) \
|
||||
or isinstance(raw_formula, dict)
|
||||
@@ -1574,6 +1600,99 @@ def _price_problems(opts: dict) -> list[str]:
|
||||
# cannot start.
|
||||
_LOG.warning("%s", aged)
|
||||
|
||||
# ⚠️ TARIFF-16: THE INJECTION LEG, REFUSED AT STARTUP ON THE SAME RULE.
|
||||
#
|
||||
# THE DEFECT THIS EXISTS TO PREVENT: `export_price_eur_kwh` models
|
||||
# injection as ONE scalar, and the published market is a line -
|
||||
# Eneco `0,1 x BELPEX-H - 1,188` c EUR/kWh, "het injectietarief is
|
||||
# dynamisch en kan per uur wijzigen", identical on the January and the
|
||||
# September 2026 cards. A scalar cannot hold its own factor (0,100 against
|
||||
# 0,102 on the same supplier's consumption leg), cannot hold a negative
|
||||
# offset, cannot state that injection is VAT-EXEMPT while consumption is
|
||||
# at 6%, and cannot go below zero in the midday hours a PV household
|
||||
# actually exports in.
|
||||
#
|
||||
# ⚠️ AND WHAT IT DOES NOT AFFECT TODAY, said here rather than left to be
|
||||
# inferred: `arbitrage.py` does not read the injection price at all. Both
|
||||
# hours it compares are all-in CONSUMPTION prices, by its own
|
||||
# accounting-basis comment. No trade turns on this option. What it changes
|
||||
# is what the operator is told and what a future export-aware strategy
|
||||
# rests on - which is why it is validated here rather than trusted.
|
||||
raw_export = opts.get(EXPORT_FORMULA_OPTION, "")
|
||||
has_export = bool(str(raw_export or "").strip()) \
|
||||
or isinstance(raw_export, dict)
|
||||
if has_export:
|
||||
try:
|
||||
xspec = parse_export_formula(raw_export)
|
||||
except FormulaInvalid as e:
|
||||
xspec = None
|
||||
problems.append(f"{EXPORT_FORMULA_OPTION} cannot be used: {e}")
|
||||
if xspec is not None:
|
||||
# ⚠️ THE 6% ASYMMETRY, PRINTED RATHER THAN ASSUMED. The two legs
|
||||
# carry INDEPENDENT `vat_pct` values and a Belgian site's are 6 and
|
||||
# 0. Printing both beside each other is the only place an operator
|
||||
# can see that the add-on knows it - a status page shows one price
|
||||
# and no arithmetic.
|
||||
_LOG.info(
|
||||
"%s is set: injection priced as (%g x index %+g) x "
|
||||
"(1 + %g/100) %s, i.e. %.4g x the wholesale price with a "
|
||||
"%+.5f EUR/kWh offset. ⚠️ NO STRATEGY IN THIS ADD-ON READS "
|
||||
"IT: arbitrage.py prices the sell side as displaced IMPORT "
|
||||
"and compares two all-in CONSUMPTION prices, so this option "
|
||||
"changes no decision the add-on takes today. It is what you "
|
||||
"are shown, and the shape a future export-aware strategy "
|
||||
"would read.",
|
||||
EXPORT_FORMULA_OPTION, xspec.factor, xspec.offset,
|
||||
xspec.vat_pct, xspec.units, xspec.passthrough,
|
||||
xspec.offset_eur_kwh)
|
||||
if spec is not None:
|
||||
# ⚠️ THE ASYMMETRY, AS AN ORDERED PAIR RATHER THAN TWO NUMBERS
|
||||
# IN ONE SENTENCE (MUTATION.md habit 14). "6 and 0 appear
|
||||
# somewhere" is satisfied by the two legs transposed, which is
|
||||
# the sentence telling an operator that the add-on has their
|
||||
# VAT treatment exactly backwards.
|
||||
_LOG.info(
|
||||
"the two legs are priced independently: consumption "
|
||||
"factor %g at vat_pct %g, injection factor %g at vat_pct "
|
||||
"%g. In Belgium those differ - \"injectietarieven zijn "
|
||||
"vrijgesteld van btw\" while consumption is at 6%% - and "
|
||||
"%s is the option that makes the difference "
|
||||
"expressible; a single scalar could not state it.",
|
||||
spec.factor, spec.vat_pct, xspec.factor, xspec.vat_pct,
|
||||
EXPORT_FORMULA_OPTION)
|
||||
if not xspec.card_graded:
|
||||
# ⚠️ A WARNING AND NEVER A REFUSAL, AND THE GAP IS NAMED
|
||||
# RATHER THAN WORKED AROUND. `price_formula`'s card block is
|
||||
# required because a Belgian card prints the consumption
|
||||
# formula, the reference index AND the resulting price. Eneco's
|
||||
# INJECTION formula is printed with no price beside it, so on
|
||||
# that card there is nothing to reproduce. Requiring a block
|
||||
# here would make the market's own published line
|
||||
# inexpressible; inventing the estimate would grade the
|
||||
# coefficients against arithmetic done with the same
|
||||
# coefficients. So the leg is accepted, the two coefficient
|
||||
# bounds in `implausible_injection()` are applied, and the
|
||||
# operator is told which of the two checks did NOT run.
|
||||
_LOG.warning(
|
||||
"%s has no \"card\" block, so its coefficients are "
|
||||
"UNGRADED: nothing recomputed a printed price from them. "
|
||||
"That is accepted because it is the real market - Eneco "
|
||||
"prints its injection formula with no price beside it, so "
|
||||
"there is nothing to grade against on that card - and "
|
||||
"refusing would make the published line inexpressible. "
|
||||
"What IS checked is the shape of the coefficients: the "
|
||||
"pass-through (%.4g x the wholesale price) and the offset "
|
||||
"(%+.5f EUR/kWh). If YOUR card prints an injection "
|
||||
"estimate, add {\"month\": ..., \"index_eur_per_mwh\": "
|
||||
"..., \"expect_incl_vat\": ...} and the add-on will "
|
||||
"refuse to start unless your numbers reproduce it.",
|
||||
EXPORT_FORMULA_OPTION, xspec.passthrough,
|
||||
xspec.offset_eur_kwh)
|
||||
else:
|
||||
xaged = stale_card(xspec)
|
||||
if xaged:
|
||||
_LOG.warning("%s", xaged)
|
||||
|
||||
# ⚠️ A WARNING, NOT A REFUSAL, AND THE ASYMMETRY IS DELIBERATE. §11.4 says a
|
||||
# site with no price data falls back to the static profile; a dynamic site
|
||||
# with none configured has nothing to fall back to when its feed dies. That
|
||||
|
||||
@@ -291,13 +291,58 @@ options:
|
||||
# price_markup_eur_kwh is ignored under it, with a line in the log saying so.
|
||||
price_provider: "off"
|
||||
price_markup_eur_kwh: 0.03
|
||||
price_taxes_eur_kwh: 0.06
|
||||
|
||||
# TARIFF-18. The all-in Flemish non-energy figure, EUR/kWh, incl. 6 % VAT.
|
||||
# Its components are named in app/price.py's FLEMISH_TAXES_COMPONENTS_EUR_KWH
|
||||
# and test_price.py section 1b re-adds them:
|
||||
#
|
||||
# Fluvius distribution (Antwerpen) 5,35 c EUR/kWh
|
||||
# Bijzondere accijns, "Alle verbruik" 4,876
|
||||
# Bijdrage groene stroom en WKK Vlaanderen 1,51
|
||||
# Energiebijdrage (0 EUR/MWh since 2026-08-01) 0
|
||||
# ------
|
||||
# 11,736 c EUR/kWh = 0.11736
|
||||
#
|
||||
# ⚠️ THIS IS PER-DSO AND YOURS IS PROBABLY DIFFERENT. Only the distribution
|
||||
# row moves: across the eight Fluvius DSOs it runs 5,28 c EUR/kWh
|
||||
# (Midden-Vlaanderen) to 6,70 (West), so the Flemish total runs about 0.117
|
||||
# to 0.131. Antwerpen is near the LOW end, which is the direction this
|
||||
# default should err in - it is inert on which hour is cheapest, but §17's
|
||||
# negative-price guard reads the ABSOLUTE all-in price, and a figure set too
|
||||
# high would carry a genuinely negative hour above zero.
|
||||
#
|
||||
# ⚠️ WALLONIA AND BRUSSELS DO NOT BELONG IN THIS SCALAR AT ALL. Their
|
||||
# distribution tariff has a day and a night band; use price_taxes_profile.
|
||||
price_taxes_eur_kwh: 0.11736
|
||||
|
||||
# §9.3: injection is priced SEPARATELY, and in Belgium it is often near zero -
|
||||
# which by itself strongly favours self-consumption over export. A scalar, not
|
||||
# a second series: no shipped supplier publishes a dynamic injection curve.
|
||||
# which by itself strongly favours self-consumption over export. This is the
|
||||
# FLAT injection price, for a site paid the same for every exported kWh.
|
||||
#
|
||||
# ⚠️ THE REASON THIS COMMENT USED TO GIVE - "no shipped supplier publishes a
|
||||
# dynamic injection curve" - WAS FALSE, and TARIFF-07 struck the same
|
||||
# sentence from app/price.py and DOCS.md without reaching this file. Eneco
|
||||
# publishes `0,1 x BELPEX-H - 1,188` c EUR/kWh on the same card as its
|
||||
# consumption formula, ENGIE publishes `(B x eSpot_15) - A`, and Aspiravi
|
||||
# `0,07 x Belpex - 2`. A site on one of those sets price_export_formula
|
||||
# below; this scalar stays the fixed-product default and is what every site
|
||||
# uses today.
|
||||
export_price_eur_kwh: 0.04
|
||||
|
||||
# TARIFF-16. The INJECTION leg as a formula, in price_formula's own grammar
|
||||
# and with its OWN coefficients: Eneco uses 0,102 on consumption and 0,100 on
|
||||
# injection, and injection is VAT-EXEMPT where consumption is at 6%, so
|
||||
# `vat_pct` here is normally 0. A negative `offset` is expected - it is what
|
||||
# the published lines carry - and the resulting price legitimately goes below
|
||||
# zero in the midday hours a PV household exports in.
|
||||
#
|
||||
# ⚠️ NO STRATEGY IN THIS ADD-ON READS IT. arbitrage.py prices the sell side
|
||||
# as displaced IMPORT and compares two all-in CONSUMPTION prices; it does not
|
||||
# read the injection price at all. This option is what the operator is shown
|
||||
# and the shape a future export-aware strategy would rest on. Empty by
|
||||
# default, which leaves every existing site on the scalar above.
|
||||
price_export_formula: ""
|
||||
|
||||
# §14's `tariffs.static_profile`, and "" is its `null`. §9.2: "a large share
|
||||
# of the installed base is on [a static profile]" - this is what makes those
|
||||
# sites first-class rather than "price_provider: off, good luck".
|
||||
@@ -359,7 +404,10 @@ options:
|
||||
#
|
||||
# ⚠️ SET THIS *OR* price_taxes_eur_kwh, NOT BOTH. Two writers of one quantity,
|
||||
# one of which silently wins, is refused at startup: leave the scalar at its
|
||||
# shipped default when you fill this in.
|
||||
# shipped default when you fill this in. A scalar still sitting on the
|
||||
# SUPERSEDED 0.06 is accepted too (TARIFF-18 moved that default, and your
|
||||
# stored options carry the old number whether you typed it or not) - the
|
||||
# refusal is about a figure you chose, not about one this add-on wrote.
|
||||
price_taxes_profile: ""
|
||||
|
||||
# TARIFF-15. YOUR OWN TARIFF CARD, as two fixed coefficients. Used only when
|
||||
@@ -876,6 +924,15 @@ schema:
|
||||
# bottoms out at 0 would make that site inexpressible.
|
||||
export_price_eur_kwh: float(-1,1)
|
||||
|
||||
# TARIFF-16. A JSON string in `price_formula`'s grammar, parsed by
|
||||
# `custom_formula.parse_export_formula()` - the SAME parser with its option
|
||||
# name as an argument, so a second unit table and a second card rule do not
|
||||
# exist to diverge. The `card` block is OPTIONAL on this leg and required on
|
||||
# the other: Eneco prints its injection formula with no price beside it, so
|
||||
# on that card there is nothing to grade against, and the add-on says at
|
||||
# startup that the leg is ungraded rather than inventing an estimate.
|
||||
price_export_formula: str?
|
||||
|
||||
# A JSON string rather than a nested schema, deliberately: it is ONE option
|
||||
# key (§14 has one), it survives config.yaml's flat options block, and
|
||||
# parse_static_profile() accepts an already-parsed dict too, so a future
|
||||
|
||||
@@ -527,6 +527,124 @@ check(f"...while THE SAME MAGNITUDES with the sign flipped all DISCHARGE, so "
|
||||
# header. Nothing in app/ changed - these rungs were correct all along.
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
print()
|
||||
print("2c. TARIFF-18 - where the \u00a717 boundary sits in SPOT terms, and the "
|
||||
"shipped default that decides it")
|
||||
# ⚠️ WHAT THIS GRADES AND WHAT IT DOES NOT CLAIM. `price_taxes_eur_kwh` is a
|
||||
# LEVEL component: it is added identically to every hour, so it cancels exactly
|
||||
# in `max - min` and cannot move which hour is cheapest. test_price.py 16b
|
||||
# measures that as a FAMILY - five flat scalars spanning and exceeding a real
|
||||
# per-DSO range, identical argmin and identical spread to the last digit - and
|
||||
# nothing here re-litigates it. Raising the shipped default 0.06 -> 0.11736 is
|
||||
# therefore NOT an arbitrage-correctness fix, and this section does not say it
|
||||
# is.
|
||||
#
|
||||
# What it IS: §17's guard is the one rung in this module that reads an
|
||||
# ABSOLUTE price rather than a difference, so it is the one decision a level
|
||||
# component can reach. The boundary is `spot < -(markup + taxes)`, and moving
|
||||
# the taxes default moves it. Below, driven through the shipped `decide()`.
|
||||
#
|
||||
# ⚠️ AND THE TWO ERROR DIRECTIONS ARE NOT SYMMETRIC, WHICH IS WHY THE DEFAULT
|
||||
# SITS AT THE BOTTOM OF THE PER-DSO BAND RATHER THAN IN THE MIDDLE. A taxes
|
||||
# figure set too HIGH carries a genuinely negative hour up above zero and the
|
||||
# add-on exports into paid-for disposal - §17's own regression case. A figure
|
||||
# set too LOW only declines a discharge that would have paid. Where one default
|
||||
# must stand in for eight Fluvius DSOs, it belongs at the low end.
|
||||
_T18_MARKUP = PRICE_OPTION_DEFAULTS["price_markup_eur_kwh"]
|
||||
_T18_TAXES = PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"]
|
||||
_T18_OLD_TAXES = 0.06 # what config.yaml shipped before TARIFF-18
|
||||
|
||||
# ⚠️ THE PRECONDITION FIRST (MUTATION.md habit 1). Every comparison below is
|
||||
# "the old level and the new level answer differently". If the two levels were
|
||||
# ever the same number, all of it would be one figure graded against itself -
|
||||
# DEV-02's `(-5000, 5000)` against `(-5000, 5000)`, one card over.
|
||||
check(f"the shipped taxes default {_T18_TAXES} and the superseded "
|
||||
f"{_T18_OLD_TAXES} are DIFFERENT numbers, and differ by more than the "
|
||||
f"0.01 EUR/kWh step this fixture's spot series is built on",
|
||||
abs(_T18_TAXES - _T18_OLD_TAXES) > 0.01)
|
||||
|
||||
# The §17 boundary, computed HERE from the two option values rather than read
|
||||
# off arbitrage.py - habit 2. all-in = spot + markup + taxes, so the guard
|
||||
# fires exactly when spot < -(markup + taxes).
|
||||
_T18_B_NEW = round(-(_T18_MARKUP + _T18_TAXES), 6)
|
||||
_T18_B_OLD = round(-(_T18_MARKUP + _T18_OLD_TAXES), 6)
|
||||
_T18_PROBE = round((_T18_B_NEW + _T18_B_OLD) / 2, 6)
|
||||
check(f"the guard's spot-price boundary moves {_T18_B_OLD:+.5f} -> "
|
||||
f"{_T18_B_NEW:+.5f} EUR/kWh, and the probe {_T18_PROBE:+.5f} lies "
|
||||
f"STRICTLY BETWEEN them - so one level answers each way and the probe is "
|
||||
f"not on either boundary",
|
||||
_T18_B_NEW < _T18_PROBE < _T18_B_OLD)
|
||||
|
||||
# A whole-day-negative spot series whose DEAREST hour is the probe. Same shape
|
||||
# as section 2's: the case a guard written "not all prices are negative" lets
|
||||
# through, in SPOT rather than all-in terms.
|
||||
_T18_SPOT = [round(-0.40 + 0.010 * i, 6) for i in range(24)]
|
||||
_T18_SPOT[DEAR_H] = _T18_PROBE
|
||||
check(f"the spot day's dearest hour is slot {DEAR_H} at {_T18_PROBE:+.5f} and "
|
||||
f"every other hour is below it, so the hour the guard is asked about is "
|
||||
f"the one the probe was chosen for",
|
||||
_T18_SPOT.index(max(_T18_SPOT)) == DEAR_H
|
||||
and _T18_SPOT.count(max(_T18_SPOT)) == 1
|
||||
and all(p < 0 for p in _T18_SPOT))
|
||||
|
||||
|
||||
def _t18_all_in(taxes):
|
||||
"""spot + markup + taxes, added here, by this file's own arithmetic."""
|
||||
return [round(p + _T18_MARKUP + taxes, 6) for p in _T18_SPOT]
|
||||
|
||||
|
||||
_T18_OLD_SERIES = _t18_all_in(_T18_OLD_TAXES)
|
||||
_T18_NEW_SERIES = _t18_all_in(_T18_TAXES)
|
||||
print(f" dearest hour all-in: old level {_T18_OLD_SERIES[DEAR_H]:+.5f}, "
|
||||
f"shipped level {_T18_NEW_SERIES[DEAR_H]:+.5f} EUR/kWh")
|
||||
|
||||
# ⚠️ THE LEVEL BUCKET RESTATED ON THIS FIXTURE, BEFORE ANYTHING IS CONCLUDED
|
||||
# FROM IT. If the two arms differed in spread or in argmin, the verdicts below
|
||||
# could be attributed to that instead, and this section would be claiming an
|
||||
# arbitrage effect it must not claim.
|
||||
check(f"the two levels leave the SPREAD identical to the last digit "
|
||||
f"({round(max(_T18_OLD_SERIES) - min(_T18_OLD_SERIES), 6)} EUR/kWh) and "
|
||||
f"the cheapest hour in the same slot - so nothing below is an optimiser "
|
||||
f"effect",
|
||||
round(max(_T18_OLD_SERIES) - min(_T18_OLD_SERIES), 6)
|
||||
== round(max(_T18_NEW_SERIES) - min(_T18_NEW_SERIES), 6)
|
||||
and _T18_OLD_SERIES.index(min(_T18_OLD_SERIES))
|
||||
== _T18_NEW_SERIES.index(min(_T18_NEW_SERIES)))
|
||||
|
||||
_T18_SELL_OLD = act(plan_of(_T18_OLD_SERIES), DEAR_H, thresh=_shipped,
|
||||
unc=NO_WEATHER)
|
||||
_T18_SELL_NEW = act(plan_of(_T18_NEW_SERIES), DEAR_H, thresh=_shipped,
|
||||
unc=NO_WEATHER)
|
||||
check(f"at the SUPERSEDED 0.06 the same spot hour is "
|
||||
f"{_T18_OLD_SERIES[DEAR_H]:+.5f} all-in, so \u00a717 REFUSES the discharge "
|
||||
f"- and the reason names \u00a717 and that price, not merely that nothing "
|
||||
f"happened",
|
||||
_T18_SELL_OLD.action is None
|
||||
and "§17" in _T18_SELL_OLD.reason
|
||||
and f"{_T18_OLD_SERIES[DEAR_H]:+.4f}" in _T18_SELL_OLD.reason)
|
||||
check(f"...and at the SHIPPED {_T18_TAXES} the SAME spot hour is "
|
||||
f"{_T18_NEW_SERIES[DEAR_H]:+.5f} all-in and the battery DISCHARGES. That "
|
||||
f"is the whole of what this card changes in a decision: the operator "
|
||||
f"really does pay those levies, so this hour was never paid-for disposal "
|
||||
f"and the old default was declining a trade that paid",
|
||||
_T18_SELL_NEW.action == DISCHARGE)
|
||||
|
||||
# ⚠️ AND THE OTHER SIDE OF THE SHIPPED BOUNDARY, or the pair above grades
|
||||
# "bigger taxes discharge more" rather than "the boundary is at -(markup +
|
||||
# taxes)". One step below the shipped boundary is still refused.
|
||||
_T18_BELOW = list(_T18_SPOT)
|
||||
_T18_BELOW[DEAR_H] = round(_T18_B_NEW - 0.001, 6)
|
||||
_T18_SELL_BELOW = act(
|
||||
plan_of([round(p + _T18_MARKUP + _T18_TAXES, 6) for p in _T18_BELOW]),
|
||||
DEAR_H, thresh=_shipped, unc=NO_WEATHER)
|
||||
check(f"a spot hour at {_T18_BELOW[DEAR_H]:+.5f} - one tenth of a cent BELOW "
|
||||
f"the shipped boundary - is still refused by \u00a717, so the boundary is "
|
||||
f"where -(markup + taxes) puts it and not merely somewhere lower than "
|
||||
f"before",
|
||||
_T18_SELL_BELOW.action is None and "§17" in _T18_SELL_BELOW.reason)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
print()
|
||||
print("3. AC3 - peak shaving outranks arbitrage, through both mechanisms")
|
||||
|
||||
+922
-27
File diff suppressed because it is too large
Load Diff
@@ -1117,34 +1117,48 @@ _T15_KEYS = ["price_formula"]
|
||||
# config.yaml and nowhere else, which is `static_profile`'s arrangement for
|
||||
# `static_profile`'s reason.
|
||||
_T17_KEYS = ["price_taxes_profile"]
|
||||
# TARIFF-16. `price_export_formula` - the INJECTION leg as `factor x index +
|
||||
# offset` with its OWN coefficients and its OWN vat_pct, because a Belgian card
|
||||
# prices injection on a second formula (Eneco 0,100 against 0,102 on
|
||||
# consumption, VAT-exempt against 6%). Like TARIFF-17's key it is an ADDITION:
|
||||
# `export_price_eur_kwh` is untouched, every site on the scalar is unaffected,
|
||||
# and it lives in this dict and in config.yaml and nowhere else.
|
||||
_T16_KEYS = ["price_export_formula"]
|
||||
check(f"the in-code mirror holds exactly TARIFF-02's, TARIFF-03's, OPT-04's, "
|
||||
f"TARIFF-15's and TARIFF-17's keys - FCST-03 still added none of its own "
|
||||
f"{_defaults}",
|
||||
f"TARIFF-15's, TARIFF-17's and TARIFF-16's keys - FCST-03 still added "
|
||||
f"none of its own {_defaults}",
|
||||
_defaults == sorted(["price_provider", "price_markup_eur_kwh",
|
||||
"price_taxes_eur_kwh", "export_price_eur_kwh",
|
||||
"price_csv_path", "price_feed_url",
|
||||
"price_horizon_h", "price_timeout_s",
|
||||
"static_profile"]
|
||||
+ _OPT04_KEYS + _T15_KEYS + _T17_KEYS))
|
||||
+ _OPT04_KEYS + _T15_KEYS + _T17_KEYS
|
||||
+ _T16_KEYS))
|
||||
# ...and the later keys are genuinely NEW, not a rename of something that was
|
||||
# already there, or the line above would pass while the mirror silently lost a
|
||||
# key.
|
||||
check("...and OPT-04's four, TARIFF-15's one and TARIFF-17's one are additions "
|
||||
"rather than replacements: the nine TARIFF-02/03 keys are all still "
|
||||
"present",
|
||||
check("...and OPT-04's four, TARIFF-15's one, TARIFF-17's one and TARIFF-16's "
|
||||
"one are additions rather than replacements: the nine TARIFF-02/03 keys "
|
||||
"are all still present",
|
||||
isinstance(_defaults, list)
|
||||
and len(set(_defaults) - set(_OPT04_KEYS) - set(_T15_KEYS)
|
||||
- set(_T17_KEYS)) == 9)
|
||||
- set(_T17_KEYS) - set(_T16_KEYS)) == 9)
|
||||
# ⚠️ AND THE ONE TARIFF-17 IS THE HOUR-VARYING TWIN OF IS STILL THERE, BY NAME.
|
||||
# The line above counts nine, and a rename of `price_taxes_eur_kwh` to
|
||||
# `price_taxes_profile` would also count nine. The scalar path being unchanged
|
||||
# is this card's first acceptance criterion, and a count cannot grade it.
|
||||
# ⚠️ THE LITERAL 0.11736 IS TARIFF-18's, AND IT IS TYPED HERE ON PURPOSE. The
|
||||
# claim is "the scalar is still its own key, holding its own real number", and
|
||||
# reading that number out of the dict under test would compare it against
|
||||
# itself. TARIFF-18 raised it from 0.06; if it moves again this line goes red
|
||||
# and whoever moved it comes here and says which card.
|
||||
check("...and `price_taxes_eur_kwh` is still its own key beside the table, so "
|
||||
"TARIFF-17 widened the framework rather than renaming the scalar",
|
||||
"TARIFF-17 widened the framework rather than renaming the scalar - and "
|
||||
"it still holds TARIFF-18's Flemish figure",
|
||||
isinstance(_defaults, list)
|
||||
and "price_taxes_eur_kwh" in _defaults
|
||||
and "price_taxes_profile" in _defaults
|
||||
and _price.PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"] == 0.06
|
||||
and _price.PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"] == 0.11736
|
||||
and _price.PRICE_OPTION_DEFAULTS["price_taxes_profile"] == "")
|
||||
check("...and every one of them is still in config.yaml, which stays the "
|
||||
"source of truth",
|
||||
|
||||
@@ -147,6 +147,16 @@ DERIVED = {
|
||||
# where the ratio came from - a citation alone would leave an operator
|
||||
# reading "0" on the tab with no idea it is not "off".
|
||||
"slew_w": ("SAFETY-39", "DERIVED", "0 MEANS FOLLOW"),
|
||||
# TARIFF-18. `price_taxes_eur_kwh` joins the table for `slew_w`'s reason:
|
||||
# it stopped being a figure somebody picked and became one SUMMED FROM
|
||||
# NAMED CARD ROWS. Three needles, because three different things about it
|
||||
# can go wrong on the Configuration tab and only the first is provenance:
|
||||
# where the number came from, that the operator's own DSO gives a
|
||||
# different one, and that changing it moves no trade - which is the claim
|
||||
# an operator is most likely to assume the opposite of when a number
|
||||
# doubles.
|
||||
"price_taxes_eur_kwh": ("TARIFF-18", "YOUR OWN DSO",
|
||||
"MOVES NO TRADING DECISION"),
|
||||
}
|
||||
_uncited = []
|
||||
for key, needles in sorted(DERIVED.items()):
|
||||
|
||||
@@ -18,6 +18,8 @@ import asyncio
|
||||
import sys
|
||||
|
||||
from app.maintenance import MAINT_OPTION_DEFAULTS, MaintConfig
|
||||
from app.price import (
|
||||
PRICE_OPTION_DEFAULTS, SUPERSEDED_TAXES_DEFAULTS_EUR_KWH)
|
||||
from app.control import LOOP_TICK_S, PLANT_SETTLE_S, SLEW_RAIL_FRAC
|
||||
from app.validate import (
|
||||
ACTUATOR_WRITE_KEYS, FIRMWARE_INGEST_VETO_S, ConfigRefused,
|
||||
@@ -1378,6 +1380,8 @@ print("TARIFF-17 - the taxes period table is refused HERE, at startup, and not "
|
||||
# healthy fixed-tariff day. That is `static_profile`'s argument, one option
|
||||
# over, and this is the same rule.
|
||||
_T17_DAG, _T17_NACHT = 0.1327, 0.0739
|
||||
_T18_SHIPPED_TAXES = PRICE_OPTION_DEFAULTS["price_taxes_eur_kwh"]
|
||||
_T18_SUPERSEDED = tuple(SUPERSEDED_TAXES_DEFAULTS_EUR_KWH)
|
||||
_T17_OK = ('{"periods":['
|
||||
'{"name":"dag","from":"07:00","to":"22:00","days":"mon-fri",'
|
||||
f'"eur_per_kwh":{_T17_DAG}}},'
|
||||
@@ -1427,11 +1431,66 @@ check("the table AND a non-default price_taxes_eur_kwh is refused, and the "
|
||||
and why(_T17_P_BOTH, "THE TABLE WINS"))
|
||||
check("...and the SHIPPED scalar beside the table is NOT refused, or every "
|
||||
"Walloon site would have to clear a key it never touched. The refusal is "
|
||||
"about a value the operator chose, and 0.06 is the one they did not",
|
||||
validate_startup_config(base(price_taxes_profile=_T17_OK,
|
||||
price_taxes_eur_kwh=0.06),
|
||||
-5000, 5000) == []
|
||||
"about a value the operator chose, and the shipped default is the one "
|
||||
"they did not",
|
||||
validate_startup_config(
|
||||
base(price_taxes_profile=_T17_OK,
|
||||
price_taxes_eur_kwh=_T18_SHIPPED_TAXES),
|
||||
-5000, 5000) == []
|
||||
and len(_T17_P_BOTH) == 1)
|
||||
|
||||
# ⚠️ TARIFF-18 - "UNTOUCHED" IS A SET, AND THIS IS THE HALF THAT DECIDES
|
||||
# WHETHER AN UPGRADE STOPS A RUNNING SITE. The Supervisor sets `App.options =
|
||||
# deepmerge(config.yaml defaults, stored options)`, so a saved blob carries
|
||||
# every schema key whether the operator typed it or not - the reference
|
||||
# install's export is 70 of 71 (CHANGELOG 0.9.0). When TARIFF-18 moved this
|
||||
# default 0.06 -> 0.11736, every such blob went from "equal to the shipped
|
||||
# default" to "not equal to it" WITHOUT ANYBODY EDITING ANYTHING. A site that
|
||||
# also carries a taxes table would have met `SystemExit(78)` on the upgrade,
|
||||
# over a number it never typed and that decides nothing. So a SUPERSEDED
|
||||
# default still reads as untouched.
|
||||
#
|
||||
# ⚠️ AND THE PRECONDITION FIRST (MUTATION.md habit 1): if the shipped default
|
||||
# and the superseded one were ever the same number, the two checks below would
|
||||
# be one check written twice, and dropping the superseded set entirely would
|
||||
# leave both green.
|
||||
check(f"the shipped taxes default {_T18_SHIPPED_TAXES} and the superseded "
|
||||
f"{_T18_SUPERSEDED} are DIFFERENT numbers, so 'the shipped one is "
|
||||
f"accepted' and 'the superseded one is accepted' are two claims",
|
||||
_T18_SHIPPED_TAXES not in _T18_SUPERSEDED and len(_T18_SUPERSEDED) >= 1)
|
||||
check(f"...and the superseded set is non-empty ({_T18_SUPERSEDED}), or the "
|
||||
f"loop below quantifies over nothing and passes on a tree that dropped "
|
||||
f"the set entirely - UX-01 AC 4's vacuous clause, one file over",
|
||||
len(_T18_SUPERSEDED) >= 1)
|
||||
for _old in _T18_SUPERSEDED:
|
||||
check(f"...and a blob that still carries the SUPERSEDED default {_old} "
|
||||
f"beside the table STARTS. That value was written into the options "
|
||||
f"file by this add-on, not typed by the operator, so refusing it "
|
||||
f"would stop a working site on an upgrade over an inert number",
|
||||
validate_startup_config(base(price_taxes_profile=_T17_OK,
|
||||
price_taxes_eur_kwh=_old),
|
||||
-5000, 5000) == [])
|
||||
# ⚠️ AND THE RUNG IS STILL A RUNG. A superseded default is not a licence for
|
||||
# any value: 0.1198 is ORES's enkelvoudig rate, a number an operator plausibly
|
||||
# types, and it is still refused beside the table. Without this line the set
|
||||
# above could be widened to "anything" and nothing would report.
|
||||
check("...while a value that is NEITHER the shipped default NOR a superseded "
|
||||
"one is still REFUSED beside the table, naming it - the set of "
|
||||
"'untouched' figures widened by exactly the old defaults and by nothing "
|
||||
"else",
|
||||
why(_T17_P_BOTH, "price_taxes_profile is set AND price_taxes_eur_kwh is "
|
||||
"0.1198")
|
||||
and 0.1198 not in _T18_SUPERSEDED
|
||||
and abs(0.1198 - _T18_SHIPPED_TAXES) > 1e-9)
|
||||
# ⚠️ AND THE REFUSAL SAYS SO, so an operator who HAS typed a number is told
|
||||
# both which figure to return to and that the old default is not the problem.
|
||||
check("...and the refusal names the SHIPPED default to return to AND says the "
|
||||
"superseded default is accepted, so the sentence is actionable on both "
|
||||
"sides of the upgrade",
|
||||
bool(_T18_SUPERSEDED)
|
||||
and why(_T17_P_BOTH, f"back to {_T18_SHIPPED_TAXES}")
|
||||
and why(_T17_P_BOTH, "SUPERSEDED")
|
||||
and all(why(_T17_P_BOTH, str(u)) for u in _T18_SUPERSEDED))
|
||||
check("...and the same non-default scalar WITHOUT the table still starts, "
|
||||
"which is what makes the line above about the PAIR rather than about "
|
||||
"0.1198 being disliked",
|
||||
@@ -1494,6 +1553,175 @@ check("...and BOTH cards divided by 100 start, which is habit 7: the refusals "
|
||||
.replace("7.10", "0.0710")), -5000, 5000) == [])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
print()
|
||||
print("TARIFF-16 - the INJECTION leg is refused HERE, at startup, and the leg "
|
||||
"the card cannot grade is SAID to be ungraded")
|
||||
# ⚠️ WHY IT IS REFUSED IN THIS MODULE. `export_price_at()` is the seam a future
|
||||
# export-aware strategy reads, and a formula that first fails when something
|
||||
# reads it is a defect discovered at the worst possible moment - which is
|
||||
# `static_profile`'s and `price_taxes_profile`'s argument, one option over.
|
||||
#
|
||||
# ⚠️ AND WHAT THIS OPTION DOES **NOT** DO, said before what it does: no
|
||||
# strategy in this add-on reads an injection price. `arbitrage.py` prices the
|
||||
# sell side as displaced IMPORT and compares two all-in CONSUMPTION prices.
|
||||
# test_price.py 17h grades that by parsing every module under app/; what is
|
||||
# graded HERE is that the operator is TOLD it, at startup, in the same breath
|
||||
# as the formula being accepted.
|
||||
import logging as _t16_logging # noqa: E402
|
||||
|
||||
|
||||
class _T16Log(_t16_logging.Handler):
|
||||
"""Every record app.validate emits during one call, rendered."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.lines = []
|
||||
|
||||
def emit(self, record):
|
||||
self.lines.append((record.levelname, record.getMessage()))
|
||||
|
||||
|
||||
def _t16_start(**over):
|
||||
"""`validate_startup_config()` -> (problems, rendered log lines).
|
||||
|
||||
⚠️ THE LEVEL IS FORCED TO INFO FOR THE DURATION AND RESTORED. Without it
|
||||
the capture returns an EMPTY list on a tree that logs correctly, which
|
||||
reads exactly like "the line is not there" - a check whose data cannot
|
||||
reach the failure it names, in the instrument rather than in the check.
|
||||
"""
|
||||
log = _t16_logging.getLogger("goodwe.config")
|
||||
h = _T16Log()
|
||||
was, log.level = log.level, _t16_logging.INFO
|
||||
log.addHandler(h)
|
||||
try:
|
||||
return validate_startup_config(base(**over), -5000, 5000), h.lines
|
||||
finally:
|
||||
log.removeHandler(h)
|
||||
log.level = was
|
||||
|
||||
|
||||
# The two published injection lines, transcribed from the cards. ⚠️ NEITHER
|
||||
# CARRIES A `card` BLOCK, because neither card prints a price beside its
|
||||
# injection formula - that is the state this section exists to grade.
|
||||
_T16_ENECO = ('{"index":"epex_be","resolution":"hourly","factor":0.1,'
|
||||
'"offset":-1.188,"units":"c_eur_per_kwh","vat_pct":0}')
|
||||
_T16_CONS = ('{"index":"epex_be","resolution":"hourly","factor":0.102,'
|
||||
'"offset":1.0,"units":"c_eur_per_kwh","vat_pct":6,'
|
||||
'"card":{"month":"2026-09","index_eur_per_mwh":133.9905,'
|
||||
'"expect_incl_vat":15.55}}')
|
||||
|
||||
# ⚠️ THE ACCEPTED BASELINE COMES FIRST (habit 7). Every refusal below varies
|
||||
# ONE field from this line, so a refusal has nowhere else to have come from.
|
||||
_T16_OK, _T16_OK_LOG = _t16_start(price_export_formula=_T16_ENECO)
|
||||
check("Eneco's real published injection line `0,1 x BELPEX-H - 1,188` STARTS - "
|
||||
"including the part that makes its price NEGATIVE below 11,88 EUR/MWh, "
|
||||
"which is the market and not a misconfiguration",
|
||||
_T16_OK == [])
|
||||
check("...and so does the shipped \"\", which is every install that exists: "
|
||||
"the option is an addition and the scalar still answers without it",
|
||||
_t16_start(price_export_formula="")[0] == []
|
||||
and _t16_start()[0] == [])
|
||||
|
||||
_T16_BAD_PT = _T16_ENECO.replace('"factor":0.1,', '"factor":10.0,')
|
||||
_T16_BAD_OFF = _T16_ENECO.replace('"offset":-1.188', '"offset":-118.8')
|
||||
_T16_P_PT = _t16_start(price_export_formula=_T16_BAD_PT)[0]
|
||||
_T16_P_OFF = _t16_start(price_export_formula=_T16_BAD_OFF)[0]
|
||||
print(f" {(_T16_P_PT or [''])[0][:118]}")
|
||||
print(f" {(_T16_P_OFF or [''])[0][:118]}")
|
||||
check("PRECONDITION: each of those two blobs differs from the accepted "
|
||||
"baseline in exactly one coefficient, so the refusals below are about "
|
||||
"the field each names",
|
||||
_T16_BAD_PT != _T16_ENECO and _T16_BAD_OFF != _T16_ENECO
|
||||
and _T16_BAD_PT.replace('"factor":10.0,', '"factor":0.1,') == _T16_ENECO
|
||||
and _T16_BAD_OFF.replace('"offset":-118.8', '"offset":-1.188')
|
||||
== _T16_ENECO)
|
||||
check("a factor 100x out is REFUSED at startup, by the pass-through rung, "
|
||||
"naming the option the operator typed",
|
||||
why(_T16_P_PT, "price_export_formula cannot be used:")
|
||||
and why(_T16_P_PT, "passes through")
|
||||
and not why(_T16_P_PT, "|offset| above"))
|
||||
check("...and an offset 100x out is refused by the OFFSET rung, so the two "
|
||||
"rungs are graded on their reasons and cannot mask each other",
|
||||
why(_T16_P_OFF, "price_export_formula cannot be used:")
|
||||
and why(_T16_P_OFF, "|offset| above")
|
||||
and not why(_T16_P_OFF, "passes through"))
|
||||
check("...and a malformed blob is refused as a malformed blob, naming the "
|
||||
"field rather than 'invalid configuration'",
|
||||
why(_t16_start(price_export_formula='{"index":"belpex_h"}')[0],
|
||||
"price_export_formula.index is 'belpex_h'"))
|
||||
|
||||
# ⚠️ THE HONEST HALF, AND IT IS A WARNING RATHER THAN A REFUSAL. Eneco prints
|
||||
# its injection formula with NO price beside it, so on that card there is
|
||||
# nothing for the self-check to reproduce. Requiring a `card` block would make
|
||||
# the published line inexpressible; inventing the estimate would grade the
|
||||
# coefficients against arithmetic done with the same coefficients. So the leg
|
||||
# starts, and the operator is told WHICH check did not run.
|
||||
_T16_UNGRADED = [m for lvl, m in _T16_OK_LOG
|
||||
if lvl == "WARNING" and "UNGRADED" in m]
|
||||
print(f" {(_T16_UNGRADED or [''])[0][:118]}")
|
||||
check("a leg with no card block starts, and says at startup that its "
|
||||
"coefficients are UNGRADED - naming what was checked instead, so the "
|
||||
"gap is stated rather than worked around",
|
||||
len(_T16_UNGRADED) == 1
|
||||
and "no \"card\" block" in _T16_UNGRADED[0]
|
||||
and "pass-through" in _T16_UNGRADED[0])
|
||||
_T16_WITH_CARD, _T16_CARD_LOG = _t16_start(
|
||||
price_export_formula=_T16_CONS, price_formula=_T16_CONS,
|
||||
price_provider="custom_formula")
|
||||
# ...and a SECOND run with the two legs genuinely different, for the ordered
|
||||
# pair below. ⚠️ THE FIRST ONE PUTS THE CONSUMPTION CARD ON BOTH LEGS, so
|
||||
# 0.102/6 appears twice and an assertion about arrangement would pass on a
|
||||
# TRANSPOSED rendering - MUTATION.md habit 4, in the fixture of a habit-14
|
||||
# check. The precondition is asserted below rather than trusted.
|
||||
_T16_BOTH_LEGS, _T16_BOTH_LOG = _t16_start(
|
||||
price_export_formula=_T16_ENECO, price_formula=_T16_CONS,
|
||||
price_provider="custom_formula")
|
||||
check("...and a leg that DOES carry a card does NOT print it, or the sentence "
|
||||
"would be noise an operator learns to ignore rather than a report of "
|
||||
"which check ran",
|
||||
_T16_WITH_CARD == []
|
||||
and not [m for lvl, m in _T16_CARD_LOG if "UNGRADED" in m])
|
||||
# ⚠️ AND A CARD ON THIS LEG IS STILL GRADED, at startup, by the same rung.
|
||||
check("...and a card ON THIS LEG that the coefficients do not reproduce is "
|
||||
"REFUSED at startup, so the optional block is optional and not inert",
|
||||
why(_t16_start(price_export_formula=_T16_CONS.replace(
|
||||
'"expect_incl_vat":15.55', '"expect_incl_vat":15.05'))[0],
|
||||
"price_export_formula does not reproduce its own card"))
|
||||
|
||||
# ⚠️ THE SENTENCE DOCS.md RESTS ON, AND IT IS THE ONE MOST LIKELY TO ROT.
|
||||
_T16_INFO = [m for lvl, m in _T16_OK_LOG if lvl == "INFO"
|
||||
and "NO STRATEGY IN THIS ADD-ON READS IT" in m]
|
||||
check("the startup line says, in so many words, that NO STRATEGY IN THIS "
|
||||
"ADD-ON READS IT - the operator is told what the option does not do in "
|
||||
"the same breath as it being accepted",
|
||||
len(_T16_INFO) == 1 and "displaced IMPORT" in _T16_INFO[0])
|
||||
# ⚠️ THE ASYMMETRY IS ASSERTED AS AN ORDERED PAIR, NOT AS TWO NUMBERS IN ONE
|
||||
# SENTENCE (MUTATION.md habit 14). "6 and 0 appear somewhere" is satisfied by
|
||||
# the two legs TRANSPOSED - which is the sentence telling an operator that the
|
||||
# add-on has their VAT treatment exactly backwards, on the one line where they
|
||||
# could have seen it.
|
||||
_T16_PAIR = [m for _l, m in _T16_BOTH_LOG if "priced independently" in m]
|
||||
print(f" {(_T16_PAIR or [''])[0][:118]}")
|
||||
check("PRECONDITION: the two legs of that run carry DIFFERENT factors and "
|
||||
"DIFFERENT VAT rates (0.102 at 6 against 0.1 at 0), or the ordered-pair "
|
||||
"assertion below would be satisfied by the transposed rendering it "
|
||||
"exists to refuse",
|
||||
_T16_BOTH_LEGS == [] and '"factor":0.102' in _T16_CONS
|
||||
and '"vat_pct":6' in _T16_CONS and '"factor":0.1,' in _T16_ENECO
|
||||
and '"vat_pct":0' in _T16_ENECO)
|
||||
check("and the 6% asymmetry is reported as an ORDERED PAIR: the transposed "
|
||||
"rendering would read `consumption factor 0.1 at vat_pct 0, injection "
|
||||
"factor 0.102 at vat_pct 6`, which is a DIFFERENT string - so an "
|
||||
"argument swap at the call site cannot hide behind `0.102 is in there "
|
||||
"somewhere`",
|
||||
len(_T16_PAIR) == 1
|
||||
and "consumption factor 0.102 at vat_pct 6, injection factor 0.1 at "
|
||||
"vat_pct 0" in _T16_PAIR[0]
|
||||
and "consumption factor 0.1 at vat_pct 0, injection factor 0.102 at "
|
||||
"vat_pct 6" not in _T16_PAIR[0])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
print()
|
||||
if fails:
|
||||
|
||||
@@ -148,8 +148,8 @@ configuration:
|
||||
name: "Tariff · Supplier markup (EUR/kWh)"
|
||||
description: "Your supplier's margin. The add-on adds it ONLY when the chosen price source does not already include it - under manual_csv, whose figures are all-in, it is ignored, and logged as ignored, never applied twice."
|
||||
price_taxes_eur_kwh:
|
||||
name: "Tariff · Levies and VAT (EUR/kWh)"
|
||||
description: "Taxes and levies per kWh, added under the same rule as the supplier markup: only when the chosen price source does not already carry them."
|
||||
name: "Tariff · Distribution, levies and VAT (EUR/kWh)"
|
||||
description: "Everything on your bill that is not the energy itself - distribution, levies, excise and VAT - per kWh, added under the same rule as the supplier markup: only when the chosen price source does not already carry them. ⚠️ THIS NUMBER IS NOT A PREFERENCE AND IT IS NOT YOUR INVERTER'S. It ships at 0.11736, DERIVED in TARIFF-18 from the Eneco residential card for Flanders of September 2026 including 6% VAT: Fluvius distribution for Antwerpen 5,35 plus bijzondere accijns 4,876 plus bijdrage groene stroom en WKK 1,51 c/kWh. The energiebijdrage is 0 since 1 August 2026 - it was merged into the excise, so a figure copied from an older guide would count it twice. ⚠️ CHECK IT AGAINST YOUR OWN DSO. Only the distribution row moves: across the eight Fluvius DSOs it runs from 5,28 c/kWh in Midden-Vlaanderen to 6,70 in West-Vlaanderen, so the Flemish total runs from about 0.117 to 0.131. In Wallonia or Brussels the distribution tariff has a separate day and night rate and does not belong in this field at all - use the levies-by-time-of-day option below instead. ⚠️ CHANGING IT MOVES NO TRADING DECISION: the same amount is added to every hour, so it cancels out of both the cheapest hour and the spread. What it does move is every price you are shown, and the rule that refuses to discharge into an hour whose all-in price is below zero."
|
||||
export_price_eur_kwh:
|
||||
name: "Tariff · Injection price (EUR/kWh)"
|
||||
description: "What you are paid for feeding a kWh back into the grid, all in. One number rather than a series: no supplier here publishes a dynamic injection curve. In Belgium it is often close to zero, which on its own strongly favours using your own production over exporting it. It may be negative - at midday in summer you can be paying to export."
|
||||
@@ -162,6 +162,9 @@ configuration:
|
||||
price_formula:
|
||||
name: "Tariff · Your own tariff formula (one line of JSON)"
|
||||
description: "For price source custom_formula only: your own contract's two coefficients, written as a single line of JSON. Your supplier's tariff card prints the formula as B x index + A - those two numbers exist only on your card, there is no public index of them anywhere, and you are the only person who can read them. Type what the card prints, IN THE UNITS THE CARD PRINTS: every unit conversion and the VAT step are the add-on's job, because those are the two places a human silently loses a factor of 10, 100 or 1.06. Example: {\"index\":\"epex_be\",\"resolution\":\"hourly\",\"factor\":0.102,\"offset\":1.00,\"units\":\"c_eur_per_kwh\",\"vat_pct\":6,\"card\":{\"month\":\"2026-09\",\"index_eur_per_mwh\":133.9905,\"expect_incl_vat\":15.55}}. ⚠️ THE card BLOCK IS REQUIRED AND IT IS WHAT MAKES THIS SAFE: your card also prints the reference index it assumed and the price that comes out, so the add-on recomputes that price from your numbers and REFUSES TO START if it does not come out, telling you by how much. That catches a wrong unit, VAT left out or counted twice, a transposed digit, and the expensive one - network charges folded into the offset, which the add-on would then bill you for a second time. ⚠️ AND ITS LIMIT, IN THE SAME BREATH: it checks your coefficients against your card, not your card against reality, so two numbers copied off the wrong product agree with each other and pass. Fixed numbers only - no expression of any kind is evaluated, and an unrecognised field is refused rather than ignored."
|
||||
price_export_formula:
|
||||
name: "Tariff · Your own INJECTION formula (one line of JSON)"
|
||||
description: "Optional, and only if your supplier pays you a price that moves with the market. Your tariff card has a SECOND formula for what you are paid for the electricity you export, and it is not the first one with a minus in front: Eneco prints `0,1 x BELPEX-H - 1,188` c/kWh for injection against `0,102 x ...` for consumption, and Aspiravi `0,07 x Belpex - 2`. Written in exactly the same shape as your own tariff formula above. ⚠️ INJECTION IS EXEMPT FROM VAT in Belgium while consumption is at 6%, so vat_pct here is normally 0 - that is the one field people copy across from the other formula and get wrong. ⚠️ THE PRICE THIS GIVES CAN BE NEGATIVE, and that is not an error: Eneco pays below zero whenever BELPEX-H is under 11,88 EUR/MWh, which is the middle of a sunny day - you can be charged to export. The add-on accepts that rather than hiding it. The card block is OPTIONAL here and required above, because Eneco prints the injection formula with NO example price beside it and there would be nothing to check your numbers against; if your card does print one, fill it in and the add-on will refuse to start unless your numbers reproduce it. ⚠️ WHAT THIS DOES NOT DO: no part of the add-on trades on an injection price today - it charges cheap to avoid buying dear, and both sides of that comparison are consumption prices. This is what you are shown, and what a future export strategy would read. Leave it empty and the flat injection price above is used, which is what every installation does now."
|
||||
price_csv_path:
|
||||
name: "Tariff · Price CSV file"
|
||||
description: "For price source manual_csv only: where in /share the add-on reads your own price file from."
|
||||
|
||||
@@ -128,8 +128,8 @@ configuration:
|
||||
name: "Tarief · Marge van de leverancier (EUR/kWh)"
|
||||
description: "De marge van uw energieleverancier. De add-on telt die ALLEEN op wanneer de gekozen prijsbron ze niet al bevat - bij manual_csv, waarvan de bedragen alles inbegrepen zijn, wordt ze genegeerd, en dat wordt ook gelogd, zodat ze nooit dubbel wordt aangerekend."
|
||||
price_taxes_eur_kwh:
|
||||
name: "Tarief · Heffingen en btw (EUR/kWh)"
|
||||
description: "Belastingen en heffingen per kWh, opgeteld volgens dezelfde regel als de marge: alleen wanneer de gekozen prijsbron ze nog niet bevat."
|
||||
name: "Tarief · Distributie, heffingen en btw (EUR/kWh)"
|
||||
description: "Alles op uw factuur dat niet de energie zelf is - distributie, heffingen, accijns en btw - per kWh, opgeteld volgens dezelfde regel als de marge: alleen wanneer de gekozen prijsbron ze nog niet bevat. ⚠️ DIT GETAL IS GEEN VOORKEUR EN HET IS NIET DAT VAN UW OMVORMER. Het staat standaard op 0.11736, AFGELEID in TARIFF-18 van de Eneco-kaart voor residentiele klanten in Vlaanderen van september 2026, inclusief 6% btw: Fluvius-distributie voor Antwerpen 5,35 plus bijzondere accijns 4,876 plus bijdrage groene stroom en WKK 1,51 c/kWh. De energiebijdrage is sinds 1 augustus 2026 nul - ze is opgegaan in de accijns, dus een bedrag uit een oudere gids telt ze dubbel. ⚠️ CONTROLEER HET BIJ UW EIGEN DISTRIBUTIENETBEHEERDER. Alleen de distributieregel verschilt: over de acht Fluvius-netgebieden loopt die van 5,28 c/kWh in Midden-Vlaanderen tot 6,70 in West-Vlaanderen, zodat het Vlaamse totaal ongeveer van 0.117 tot 0.131 loopt. In Wallonie en Brussel heeft het distributietarief een apart dag- en nachttarief en hoort het hier helemaal niet thuis - gebruik dan de optie voor heffingen per tijdstip hieronder. ⚠️ DIT WIJZIGEN VERANDERT GEEN ENKELE HANDELSBESLISSING: hetzelfde bedrag komt bij elk uur, dus het valt weg uit zowel het goedkoopste uur als het prijsverschil. Wat het wel verandert is elke prijs die u te zien krijgt, en de regel die weigert te ontladen in een uur waarvan de totaalprijs onder nul ligt."
|
||||
export_price_eur_kwh:
|
||||
name: "Tarief · Injectievergoeding (EUR/kWh)"
|
||||
description: "Wat u krijgt voor een kWh die u op het net zet, alles inbegrepen. Eén getal en geen reeks: geen enkele leverancier hier publiceert een dynamische injectiecurve. In België ligt dit vaak dicht bij nul, wat op zich al sterk pleit voor eigenverbruik in plaats van injectie. De waarde mag negatief zijn - op een zomerse middag betaalt u soms om te injecteren."
|
||||
@@ -142,6 +142,9 @@ configuration:
|
||||
price_formula:
|
||||
name: "Tarief · Uw eigen tariefformule (één regel JSON)"
|
||||
description: "Alleen voor prijsbron custom_formula: de twee coëfficiënten van uw eigen contract, als één regel JSON. De tariefkaart van uw leverancier drukt de formule af als B x index + A - die twee getallen staan alleen op uw kaart, er bestaat nergens een publieke lijst van, en u bent de enige die ze kan lezen. Typ wat de kaart afdrukt, IN DE EENHEID DIE DE KAART GEBRUIKT: elke eenheidsomrekening en de btw-stap zijn het werk van de add-on, want dat zijn precies de twee plaatsen waar een mens stilzwijgend een factor 10, 100 of 1,06 verliest. Voorbeeld: {\"index\":\"epex_be\",\"resolution\":\"hourly\",\"factor\":0.102,\"offset\":1.00,\"units\":\"c_eur_per_kwh\",\"vat_pct\":6,\"card\":{\"month\":\"2026-09\",\"index_eur_per_mwh\":133.9905,\"expect_incl_vat\":15.55}}. ⚠️ HET BLOK card IS VERPLICHT EN MAAKT DIT VEILIG: uw kaart vermeldt ook de referentie-index die ze veronderstelt en de prijs die eruit volgt, dus de add-on berekent die prijs opnieuw uit uw getallen en START NIET als het resultaat niet klopt - met vermelding van het verschil. Dat vangt een verkeerde eenheid, btw die ontbreekt of dubbel geteld is, een omgewisseld cijfer, en de dure fout: nettarieven die in de offset verwerkt zitten en die de add-on er dan nog een tweede keer bovenop zou rekenen. ⚠️ EN DE GRENS DAARVAN, IN DEZELFDE ZIN: ze toetst uw coëfficiënten aan uw kaart, niet uw kaart aan de werkelijkheid - twee getallen van het verkeerde product kloppen onderling en komen er dus door. Alleen vaste getallen: er wordt geen enkele expressie geëvalueerd, en een onbekend veld wordt geweigerd in plaats van genegeerd."
|
||||
price_export_formula:
|
||||
name: "Tarief · Uw eigen INJECTIEformule (één regel JSON)"
|
||||
description: "Optioneel, en alleen als uw leverancier u een prijs betaalt die met de markt meebeweegt. Op uw tariefkaart staat een TWEEDE formule voor wat u krijgt voor de stroom die u injecteert, en dat is niet de eerste met een minteken ervoor: Eneco drukt `0,1 x BELPEX-H - 1,188` c/kWh af voor injectie tegenover `0,102 x ...` voor afname, en Aspiravi `0,07 x Belpex - 2`. Geschreven in precies dezelfde vorm als uw eigen tariefformule hierboven. ⚠️ INJECTIE IS IN BELGIË VRIJGESTELD VAN BTW terwijl afname op 6% staat, dus vat_pct is hier normaal 0 - dat is het ene veld dat men van de andere formule overneemt en verkeerd invult. ⚠️ DE PRIJS DIE HIERUIT VOLGT KAN NEGATIEF ZIJN, en dat is geen fout: Eneco betaalt onder nul zodra BELPEX-H lager is dan 11,88 EUR/MWh, en dat is het midden van een zonnige dag - u kunt moeten betalen om te injecteren. De add-on aanvaardt dat in plaats van het te verbergen. Het blok card is hier OPTIONEEL en hierboven verplicht, omdat Eneco de injectieformule afdrukt ZONDER voorbeeldprijs ernaast en er dan niets is om uw getallen aan te toetsen; drukt uw kaart er wél een af, vul ze dan in en de add-on start niet als uw getallen die prijs niet reproduceren. ⚠️ WAT DIT NIET DOET: geen enkel onderdeel van de add-on handelt vandaag op een injectieprijs - hij laadt goedkoop op om duur te vermijden, en beide zijden van die vergelijking zijn afnameprijzen. Dit is wat u te zien krijgt, en wat een toekomstige exportstrategie zou lezen. Laat het leeg en de vaste injectieprijs hierboven wordt gebruikt, zoals elke installatie nu doet."
|
||||
price_csv_path:
|
||||
name: "Tarief · CSV-bestand met prijzen"
|
||||
description: "Alleen voor prijsbron manual_csv: waar in /share de add-on uw eigen prijsbestand leest."
|
||||
|
||||
Reference in New Issue
Block a user