fix(load): do not turn on a minimum-power load when the surplus cannot cover it#7
Merged
Merged
Conversation
…t cover it A numeric load with absolute_min_w (e.g. an EV charger that requires at least 6 A / 1380 W when on) was snapped up to that minimum for any surplus, however small. A 300 W surplus turned the charger on at 1380 W, creating over 1 kW of grid import that the controller then had to correct by curtailing PV or reducing other loads. The load now only turns on from off when the available surplus covers absolute_min_w — consistent with how switch loads already gate on their fixed power. Reducing toward off (snap down to 0) is unchanged. https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A numeric load with a minimum active power (
absolute_min_w, e.g. an EV charger that requires at least 6 A / 1380 W when on) was snapped up to that minimum for any surplus, however small. With a 300 W surplus the charger turned on at 1380 W, creating over 1 kW of grid import that the controller then had to correct by curtailing PV or reducing other loads — the opposite of what the surplus-distribution step is supposed to do.Fix
A load that is off (below its minimum active power) now only turns on when the available surplus actually covers
absolute_min_w— consistent with how switch loads already gate their turn-on onpower_w. Reducing toward off (snap down to 0 through the forbidden zone) is unchanged.Tests
Two tests in
tests/test_load_control.py: the load stays off at 300 W surplus (no write, surplus untouched for the next actuator), and turns on normally once the surplus covers the minimum. The old test that codified the over-absorb behaviour is replaced. Full suite: 239 passed.This is the last remaining fix from the earlier control-loop review; with this, everything from that series is on
devand PR #1 can be closed as superseded.https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
Generated by Claude Code