Skip to content

Reset daily peak power readings at the start of a solar day - #135

Draft
Solarboaters wants to merge 2 commits into
LibreSolar:mainfrom
Solarboaters:fix/daily-power-maxima
Draft

Solarboaters wants to merge 2 commits into
LibreSolar:mainfrom
Solarboaters:fix/daily-power-maxima

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 12, 2026 •

Copy link
Copy Markdown

The reported solar/load pPowerMaxToday_W values persist across day changes because update_energy resets the daily energy counters at sunrise but never resets solar_power_max_day or load_power_max_day.

Reset both daily peaks alongside the daily energy counters. The lifetime peak fields retain their values.

Extended the existing sunrise regression test to assert daily-peak reset and lifetime-peak preservation. An isolated C++ harness executing update_energy with stand-ins reproduced the original retained peaks after a simulated night and sunrise and passed with the patch. The full Zephyr test suite and hardware test have not been run.

Audit status (16 November 2026): returned to draft pending actual firmware/test execution. The current GitHub runner fails in setup because apt cannot locate clang-format-15; this occurs before the firmware build and tests. The isolated harness evidence above remains limited to that scope. No successful full CI or hardware test is claimed.

Evidence audit — 17 November 2026

Individually rebuilt and ran the production Zephyr native test image from public revision fc6a8de: 95 tests, zero failures. This is separate from the combined run of #135–#145, which passes all 103 tests. Replacing the relevant production implementations with the original code reproduces the new regression failures.

Reproduction in the west workspace, from the firmware directory:

ZEPHYR_TOOLCHAIN_VARIANT=host west build -b native_sim/native/64 -d ../build tests -- -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DDTC_OVERLAY_FILE=boards/native_sim.overlay
../build/zephyr/zephyr.exe

Environment: Linux x86-64, GCC host toolchain, Zephyr 4.4.2, manifest dependencies. These tests use the project's native simulated interfaces; no ARM board or charging hardware was operated.

The audit also corrected test isolation: each peak-power test now initializes its own daily and lifetime peak state. This prevents the preceding daily-reset test from contaminating later checks.

The earlier GitHub CI failure was a runner setup failure locating clang-format-15, before source tests ran. The local native result above does not turn that CI run green; board firmware CI remains unverified.

@Solarboaters
Solarboaters marked this pull request as draft November 16, 2026 21:54
@martinjaeger

Copy link
Copy Markdown
Member

@Solarboaters Thanks for all your PRs!

In most (all?) of them you write that you didn't run the PRs on any charge controller hardware. Do you have actual hardware? Are you planning to test it there?

Don't get me wrong, but I'm wondering what your motivation behind these PRs is if they are not solving real issues you encountered while running the firmware.

I was working on a major update of the firmware, converting the legacy "drivers" into actual Zephyr-style drivers: https://github.com/LibreSolar/charge-controller-firmware/tree/zephyr-driver

This will probably fix some of the issues you encountered, but it also means that we will run into several merge conflicts. Given the amount of changes in the new branch I would prefer merging that first and afterwards rebasing your small and separate changes. It will create less conflicts and effort than rebasing that branch on top of your changes.

I assume you implemented those fixes with the help of AI, correct? If so, can you please leave the "Co-authored by" in the commits? And if the implementations were done with AI, I hope it would also be able to assist in rebasing the fixes on top of the new branch, right?

Let me know what you think.

@Solarboaters

Copy link
Copy Markdown
Author

Thanks, Martin, and apologies for the delayed reply.

We don't have Libre Solar charge-controller hardware available to validate these changes, and there isn't a scheduled hardware test. We have since run the project's native simulated tests, but that is not a substitute for testing an actual controller. We won't describe these as hardware-validated.

Our motivation is an interest in marine solar and battery systems and a wish to contribute useful fixes to software we may use. These proposals came from code investigation rather than faults we encountered while operating your firmware. We recognise that usefulness and review effort matter as much as a passing test.

Yes, the implementations and test preparation are AI-assisted. We will include the requested AI co-author attribution in the rebased commits. We can also use that assistance to rebase, inspect the resulting changes and rerun the relevant tests, without claiming that replaces hardware validation.

Your proposed order makes sense: let the zephyr-driver work land first. We'll pause further charger submissions and requests for review, then reassess which fixes are still relevant, drop those already addressed, and rebase the remaining small changes. There is no need to work around our PRs to accommodate the larger update.

This branch has not been deployed

No deployments
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.

2 participants