Skip to content

Update to upstream v8.40.10 while preserving FIT payments#6

Merged
dandwhelan merged 583 commits into
mainfrom
claude/wonderful-ptolemy-dyws88
Jun 16, 2026
Merged

Update to upstream v8.40.10 while preserving FIT payments#6
dandwhelan merged 583 commits into
mainfrom
claude/wonderful-ptolemy-dyws88

Conversation

@dandwhelan

Copy link
Copy Markdown
Owner

Summary

Merges the latest build from upstream springfall2008/batpred (now v8.40.10, ~581 commits ahead of our previous base of v8.36.3) into the fork, while keeping the full Feed-in Tariff (FIT) payment feature intact.

What changed

  • Merged upstream/main (v8.40.10) into the branch. The auto-merge cleanly carried the FIT code in config.py, fetch.py, prediction.py, plan.py, output.py, tests/test_fit.py, tests/test_infra.py and CLAUDE.md.
  • Resolved the one conflict in unit_test.py, keeping both the FIT test registration and upstream's new storage test registration.
  • Adapted FIT tests to an upstream change: upstream's simple_scenario now asserts total PV clipping. The two FIT clipping scenarios deliberately clip ~36 kWh, so they now declare assert_clipped=36.
  • Hardened calculate_yesterday: FIT income is now read with getattr(..., 0) so the upstream test_calculate_yesterday path (which mocks run_prediction and never sets the FIT attributes) no longer raises, and FIT income correctly defaults to 0 when FIT is disabled or the prediction wasn't saved.

Verification

  • ./run_all --test fitPASSED (all 6 FIT scenarios)
  • ./run_all --quickall tests PASSED
  • pre-commit (ruff, black, cspell, etc.) → PASSED

All FIT payment functionality — generation tariff, deemed export, clipping-aware income, and the fit_income / fit_income_best / fit_income_yesterday sensors — is preserved.

🤖 Generated with Claude Code


Generated by Claude Code

springfall2008 and others added 30 commits May 25, 2026 10:49
Preserve manual DoD/usable config when battery_scaling_auto is enabled by introducing battery_scaling_config and clamping auto-scaling to [config*0.8, config]. Update Inverter to set battery_scaling from the computed value and to default battery_scaling to 1.0 when no nominal capacity is configured. Add/adjust unit tests: helper _clamped_auto_scaling, assert battery_scaling is updated in existing auto-scaling tests, add test_battery_scaling_auto_preserves_configured_scaling to ensure measured degradation below configured DoD is applied, and wire the new test into the test runner.
Update Sig Energy service calls in inverter setup documentation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Fix: Tesla Powerwall setup instructions and example
pre-commit-ci-lite Bot and others added 28 commits June 15, 2026 06:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Reset GECloud defaults after 24 hours, Add 100w base load default, catch crash with MinuteData array
…-token-size

Fix: Tesla access token field size
Revise Huawei inverter setup in documentation
…expired JWT

The gateway MQTT access token is a short-lived (24h) JWT. When it expired,
_mqtt_loop reconnected forever with the same rejected token — the broker
returns CONNACK code 134 ("Bad user name or password") on every attempt — so
PredBat silently lost all gateway control until the pod/config was rebuilt.
The proactive near-expiry refresh in _check_token_refresh runs from the
housekeeping loop, which does not help once the listener is stuck reconnecting.

Make the reconnect loop self-healing: on a broker auth-failure it now forces a
token refresh before retrying, instead of looping on the dead token.

- _is_auth_failure(): classify CONNACK 134/135 auth rejections vs ordinary drops
- _maybe_refresh_on_auth_error(): force a refresh only for auth failures
- _do_token_refresh() / _apply_refresh_response(): extracted from
  _check_token_refresh so the proactive and reconnect paths share one refresh
- wired into _mqtt_loop's exception handler

Adds test_gateway_token_refresh.py (12 tests); existing gateway tests stay green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… on load

When a cached model is loaded at startup, last_train_time was left None,
causing the training-age check to treat the model as infinitely old and
force an immediate retrain. Use predictor.training_timestamp (already
restored from the .npz metadata by LoadPredictor.load) rather than the
filesystem mtime, which can be wrong after file copies or backup restores.

If training_timestamp is None (pre-dating that field), last_train_time
stays None and a retrain correctly triggers as a safe fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rain_time

fix(ml): set last_train_time from model's embedded training_timestamp on load
…y-mqtt-token-refresh-on-auth

fix(gateway): refresh MQTT token on broker auth-failure to self-heal expired JWT
Fix GECloud and standalone PV, Fox cache updates
…olemy-dyws88

# Conflicts:
#	apps/predbat/unit_test.py
- Resolve unit_test.py conflict keeping both FIT and storage test registration
- Declare expected clipping (assert_clipped=36) in FIT clipping tests, now that
  upstream's simple_scenario asserts total clipping
- Default FIT income to 0 via getattr in calculate_yesterday so the mocked
  run_prediction path in test_calculate_yesterday no longer raises

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139MJfnebYZdxUEntj7FFMg
@dandwhelan dandwhelan marked this pull request as ready for review June 16, 2026 21:57
@dandwhelan dandwhelan merged commit eb6a40e into main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.