You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c60700d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+2-56Lines changed: 2 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,64 +141,10 @@ mkdocs serve # Live preview at http://localhost:8000
141
141
142
142
When adding a new doc page, add it to `mkdocs.yml`. The published site at <https://springfall2008.github.io/batpred/> is built automatically from `main` via GitHub Actions.
143
143
144
-
## Feed-in Tariff (FIT) Support
145
-
146
-
Predbat supports UK Feed-in Tariff schemes where users earn a generation tariff on all solar production plus a deemed export payment on a percentage of generation (typically 50%).
147
-
148
-
### How It Works
149
-
150
-
FIT is off by default. When the `metric_fit_enable` master switch is turned on **and**`metric_fit_generation_rate` is set above 0 (both Expert Mode), FIT mode is activated:
151
-
152
-
-**Export rate zeroed in optimizer**: Since deemed export pays regardless of actual export, the optimizer treats actual export as having zero additional value. This makes the optimizer prefer self-consumption of solar over exporting it.
153
-
-**Battery headroom for solar**: The optimizer will not charge the battery to 100% from the grid when solar generation is forecast, leaving room for solar to charge the battery during the day.
154
-
-**FIT income tracked**: Generation and deemed export income are subtracted from the cost metric for accurate cost/savings display.
155
-
156
-
Turning `metric_fit_enable` off zeroes the FIT rates at config-load time (`Fetch.fit_apply_enable()`), so every downstream consumer — the Python prediction engine, the C++ kernel, and the published sensors — sees FIT as inactive without the user having to clear their configured rates. Because this gate lives at the single point where rates are loaded, no kernel change or ABI bump is required for the toggle.
157
-
158
-
### Config Items
159
-
160
-
All under Expert Mode in `config.py`:
161
-
162
-
| Setting | Default | Description |
163
-
|---------|---------|-------------|
164
-
|`metric_fit_enable`| False | Master switch (off by default); must be turned on to activate FIT, otherwise all FIT behaviour is disabled and configured rates are ignored |
165
-
|`metric_fit_generation_rate`| 0 p/kWh | FIT generation tariff rate |
|`predbat.fit_income`| Predicted FIT income (base plan) |
174
-
|`predbat.fit_income_best`| Predicted FIT income (best/optimised plan) |
175
-
|`predbat.fit_income_yesterday`| Predicted FIT income for yesterday's baseline |
176
-
177
-
All sensors include attributes: `generation_income`, `deemed_export_income`, `generation_rate`, `deemed_export_rate`, `deemed_export_percentage`.
178
-
179
-
### Key Files
180
-
181
-
| File | What changed |
182
-
|------|-------------|
183
-
|`config.py`|`metric_fit_enable` master switch plus three FIT rate `CONFIG_ITEMS` entries |
184
-
|`fetch.py`| Loads FIT config values, applies the `metric_fit_enable` gate (`fit_apply_enable()`), logs when FIT is enabled or disabled by the switch |
185
-
|`prediction.py`| Zeros export rate when FIT enabled; tracks FIT income per simulation step |
186
-
|`plan.py`| Extracts FIT income from prediction results; publishes `fit_income` / `fit_income_best` sensors |
187
-
|`output.py`| Extracts FIT income from yesterday predictions; publishes `fit_income_yesterday` sensor |
188
-
|`tests/test_infra.py`| FIT defaults (including `metric_fit_enable`) added to test config and `reset_inverter()`|
189
-
|`tests/test_fit.py`| Covers the FIT calculator plus the `metric_fit_enable` master-switch toggle |
190
-
|`prediction_kernel.cpp` / `prediction_kernel.py`| FIT rates passed into the C++ kernel; per-step clipped-PV tracking, export-rate zeroing and FIT income metric adjustment mirrored in the kernel (fork ABI/parity revision 103) |
191
-
|`tests/test_kernel_parity.py`| FIT deterministic edge cases and FIT rate randomisation in the parity sweep |
192
-
193
-
### C++ Kernel Note (fork)
194
-
195
-
This fork's kernel binaries are built with ABI/parity revision **103** (upstream uses small integers like 2). Any change to the FIT logic in `prediction.py`'s hot loop must be mirrored in `prediction_kernel.cpp` and both revision numbers bumped, then all six `prediction_kernel_lib_*.so` binaries rebuilt via `build_kernel_cross.sh` (zig). When merging from upstream, re-apply the FIT kernel support if upstream bumps its ABI, and keep this fork's revision numbers strictly above upstream's.
196
-
197
144
## Fork-Specific Notes
198
145
199
-
This repository is a personal fork of `springfall2008/batpred` (currently based on upstream v8.46.4). Fork changes on top of upstream:
146
+
This repository is a personal fork of `springfall2008/batpred` (currently based on upstream v9.3.0). Fork changes on top of upstream:
200
147
201
-
-**FIT support** — see the Feed-in Tariff section above
202
148
-**Custom web dashboard** — the port-5052 web UI has a `/dash_entities` page and a redesigned power flow diagram (`web.py`, `web_helper.py`)
203
149
-**DB history fix** — `db_manager`/HA history returns correct results for entities with no state change inside the query window
204
150
-**Fork release pipeline** — see below
@@ -214,7 +160,7 @@ Installations tracking this fork self-update from these releases via Predbat's b
214
160
215
161
### Merging from upstream
216
162
217
-
When merging `upstream/main`, preserve the FIT feature (Python + C++ kernel), the custom dashboard, and the fork release workflow. If upstream bumps its kernel ABI revision, re-apply FIT kernel support and keep the fork's revision strictly above upstream's, then rebuild all six kernel binaries.
163
+
When merging `upstream/main`, preserve the custom dashboard, the GivTCP export-target handling, the database changes and the fork release workflow. FIT support was removed in v712.35.
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-55Lines changed: 3 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,68 +166,16 @@ mkdocs serve # Live preview at http://localhost:8000
166
166
167
167
When adding a new doc page, add it to `mkdocs.yml`. The published site at <https://springfall2008.github.io/batpred/> is built automatically from `main` via GitHub Actions.
168
168
169
-
## Feed-in Tariff (FIT) Support
170
-
171
-
Predbat supports UK Feed-in Tariff schemes where users earn a generation tariff on all solar production plus a deemed export payment on a percentage of generation (typically 50%).
172
-
173
-
### How It Works
174
-
175
-
FIT is off by default. When the `metric_fit_enable` master switch is turned on **and**`metric_fit_generation_rate` is set above 0 (both Expert Mode), FIT mode is activated:
176
-
177
-
-**Export rate zeroed in optimizer**: Since deemed export pays regardless of actual export, the optimizer treats actual export as having zero additional value. This makes the optimizer prefer self-consumption of solar over exporting it.
178
-
-**Battery headroom for solar**: The optimizer will not charge the battery to 100% from the grid when solar generation is forecast, leaving room for solar to charge the battery during the day.
179
-
-**FIT income tracked**: Generation and deemed export income are subtracted from the cost metric for accurate cost/savings display.
180
-
181
-
Turning `metric_fit_enable` off zeroes the FIT rates at config-load time (`Fetch.fit_apply_enable()`), so every downstream consumer — the Python prediction engine, the C++ kernel, and the published sensors — sees FIT as inactive without the user having to clear their configured rates. Because this gate lives at the single point where rates are loaded, no kernel change or ABI bump is required for the toggle.
182
-
183
-
### Config Items
184
-
185
-
All under Expert Mode in `config.py`:
186
-
187
-
| Setting | Default | Description |
188
-
|---------|---------|-------------|
189
-
|`metric_fit_enable`| False | Master switch (off by default); must be turned on to activate FIT, otherwise all FIT behaviour is disabled and configured rates are ignored |
190
-
|`metric_fit_generation_rate`| 0 p/kWh | FIT generation tariff rate |
|`predbat.fit_income`| Predicted FIT income (base plan) |
199
-
|`predbat.fit_income_best`| Predicted FIT income (best/optimised plan) |
200
-
|`predbat.fit_income_yesterday`| Predicted FIT income for yesterday's baseline |
201
-
202
-
All sensors include attributes: `generation_income`, `deemed_export_income`, `generation_rate`, `deemed_export_rate`, `deemed_export_percentage`.
203
-
204
-
### Key Files
205
-
206
-
| File | What changed |
207
-
|------|-------------|
208
-
|`config.py`|`metric_fit_enable` master switch plus three FIT rate `CONFIG_ITEMS` entries |
209
-
|`fetch.py`| Loads FIT config values, applies the `metric_fit_enable` gate (`fit_apply_enable()`), logs when FIT is enabled or disabled by the switch |
210
-
|`prediction.py`| Zeros export rate when FIT enabled; tracks FIT income per simulation step |
211
-
|`plan.py`| Extracts FIT income from prediction results; publishes `fit_income` / `fit_income_best` sensors |
212
-
|`output.py`| Extracts FIT income from yesterday predictions; publishes `fit_income_yesterday` sensor |
213
-
|`tests/test_infra.py`| FIT defaults (including `metric_fit_enable`) added to test config and `reset_inverter()`|
214
-
|`tests/test_fit.py`| Covers the FIT calculator plus the `metric_fit_enable` master-switch toggle |
215
-
|`prediction_kernel.py`|`kernel_supported()` returns False when a FIT rate is set, so a FIT run uses the Python engine rather than the FIT-blind C++ kernel |
216
-
|`tests/test_kernel_parity.py`| FIT deterministic edge cases and FIT rate randomisation in the parity sweep |
217
-
218
-
### C++ Kernel Note (fork)
219
-
220
-
**FIT is Python-only.** The kernel carried FIT fields in `PkContext` at fork ABI/parity 103-105 until the 2026-08-24 upstream merge dropped them; the fork is now back on upstream's plain numbering (currently **7/14**) and the C++ kernel knows nothing about FIT. `kernel_supported()` therefore returns False whenever `metric_fit_generation_rate` or `metric_fit_deemed_export_rate` is above zero, so a FIT user falls back to the Python engine and gets the plan they configured for, just more slowly. Covered by `tests/test_fit.py`. If FIT is ever re-added to the kernel, that gate is what to remove.
169
+
## C++ Kernel Note (fork)
221
170
222
171
**The fork's kernel source is not upstream's.** Both sit at ABI/parity 7/14, but this fork carries its own C++ work on top: an exact-integer `round_py` fast path (~7ns vs upstream's ~96ns snprintf/strtod), a `shared_ptr` context map so `pk_context_free` on another thread cannot free a running context, a `calc_percent_limit` clamp at zero, the `pk_round_py_test` hook, and a `kernel_n_steps` guard. Because the revision numbers match upstream's, **the loader cannot tell fork binaries from upstream ones** — so on any upstream merge that touches `prediction_kernel.cpp`, taking either side's `.so` files wholesale is wrong. Merge the source, then rebuild all six `prediction_kernel_lib_*.so` from the merged tree via `build_kernel_cross.sh` (needs zig; `ZIG=/path/to/zig bash apps/predbat/build_kernel_cross.sh`) and confirm with `./run_all --test kernel_parity`.
223
172
224
173
Any behavioural change to `prediction.py`'s hot loop must still be mirrored in `prediction_kernel.cpp` with `KERNEL_PARITY_REVISION` and `PK_PARITY_REVISION` both bumped, followed by a rebuild of all six binaries.
225
174
226
175
## Fork-Specific Notes
227
176
228
-
This repository is a personal fork of `springfall2008/batpred` (currently based on upstream v9.0.3). Fork changes on top of upstream:
177
+
This repository is a personal fork of `springfall2008/batpred` (currently based on upstream v9.3.0). Fork changes on top of upstream:
229
178
230
-
-**FIT support** — see the Feed-in Tariff section above
231
179
-**Custom web dashboard** — the port-5052 web UI has a `/dash_entities` page and a redesigned power flow diagram (`web.py`, `web_helper.py`)
232
180
-**DB history fix** — `db_manager`/HA history returns correct results for entities with no state change inside the query window
233
181
-**GivTCP export-target robustness** — `givtcp_rest.py` treats GivTCP's own POST acknowledgement as proof a discharge-target write landed (some inverters never read the register back), and suppresses the every-cycle rewrite for a target already seen to be unwritable (`base.rest_discharge_target_unwritable`). Ported into the component when upstream moved REST out of `inverter.py`.
@@ -244,7 +192,7 @@ Installations tracking this fork self-update from these releases via Predbat's b
244
192
245
193
### Merging from upstream
246
194
247
-
When merging `upstream/main`, preserve the FIT feature (Python + C++ kernel), the custom dashboard, and the fork release workflow. If upstream bumps its kernel ABI revision, re-apply FIT kernel support and keep the fork's revision strictly above upstream's, then rebuild all six kernel binaries.
195
+
When merging `upstream/main`, preserve the custom dashboard, the GivTCP export-target handling, the database changes and the fork release workflow. FIT support was removed in v712.35.
Copy file name to clipboardExpand all lines: README.md
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,7 @@
6
6
7
7
## About this fork
8
8
9
-
This is a personal fork of [springfall2008/batpred](https://github.com/springfall2008/batpred) with the following additions on top of upstream (currently based on upstream v8.49.0):
10
-
11
-
### Feed-in Tariff (FIT) support
12
-
13
-
UK FIT scheme support for solar self-consumption optimisation. FIT is off by default; when the `metric_fit_enable` master switch is turned on and `metric_fit_generation_rate` is set (Expert Mode), the optimiser treats actual export as having no additional value (deemed export pays regardless), prefers self-consumption of solar, and leaves battery headroom for forecast solar rather than grid-charging to 100%. Turning `metric_fit_enable` off disables all FIT behaviour while leaving the configured rates in place. Adds config items `metric_fit_enable`, `metric_fit_generation_rate`, `metric_fit_deemed_export_rate` and `metric_fit_deemed_export_percentage`, plus sensors `predbat.fit_income`, `predbat.fit_income_best` and `predbat.fit_income_yesterday`. FIT logic is also implemented in the C++ prediction kernel (fork ABI revision 103) with parity tests, and all six platform kernel binaries are rebuilt with FIT support.
9
+
This is a personal fork of [springfall2008/batpred](https://github.com/springfall2008/batpred) with the following additions on top of upstream (currently based on upstream v9.3.0):
14
10
15
11
### Custom web dashboard
16
12
@@ -23,7 +19,6 @@ This fork publishes its own GitHub releases (versioned `v712.xx`) via a release
23
19
### Fixes
24
20
25
21
* Database history now returns correct results for entities with no state change inside the query window
26
-
* FIT payment calculator bug fixes
27
22
* cspell dictionary ordering fixed to match the pre-commit hook
0 commit comments