-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: configurable loadpoint priority strategy (soc/deficit) with hysteresis #31072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Alexxtheonly
wants to merge
19
commits into
evcc-io:master
Choose a base branch
from
Alexxtheonly:feat/loadpoint-priority-strategy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a299f71
feat: configurable loadpoint priority strategy (soc, deficit)
8b2f970
feat: add priorityHysteresis deadband to loadpoint priority sub-ordering
c156d76
feat: wire priorityStrategy and priorityHysteresis as runtime loadpoi…
4d8d964
feat(openapi): add priorityStrategy and priorityHysteresis loadpoint …
ba2ee38
feat(ui): add priorityStrategy and priorityHysteresis loadpoint controls
55a0572
feat: include priorityStrategy/priorityHysteresis in loadpoint Dynami…
2ce7052
feat(ui): expose priorityStrategy/priorityHysteresis in loadpoint con…
4e9f364
fix(test): gci import order + disambiguate Priority locator
89e09d7
feat: add priorityBasis (percent/energy) to loadpoint priority strategy
df69798
feat(ui): expose priorityBasis in both loadpoint modals
6f17f60
chore: regenerate mock + gofmt for priority basis
697d443
chore: fix gofmt comment alignment on capacity-unknown row
88a8662
fix: rank a priority tier on one basis to avoid mixing kWh and percent
4617906
refactor(loadpoint): address review — TextUnmarshaler guard, drop Str…
16abf9f
refactor(loadpoint): enumer-based priority enums, rename static->none
d7c0f4f
fix(ui): default new loadpoint priority strategy/basis to none/percent
216274c
chore(mcp): regenerate openapi.json for none enum (porcelain check)
a32c09c
Merge branch 'master' into feat/loadpoint-priority-strategy
Alexxtheonly 4fe8836
feat: publish effectivePriorityScore via API
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package api | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| // PriorityStrategy determines how a loadpoint is ranked against other loadpoints | ||
| // of the same priority when distributing surplus power. Valid values are static, | ||
| // soc and deficit. | ||
| type PriorityStrategy string | ||
|
|
||
| // Priority strategies | ||
| const ( | ||
| // PriorityStatic ranks loadpoints by their configured priority only (default). | ||
| PriorityStatic PriorityStrategy = "" | ||
| // PrioritySoc additionally prefers the loadpoint with the lower vehicle soc | ||
| // among loadpoints of the same priority. | ||
| PrioritySoc PriorityStrategy = "soc" | ||
| // PriorityDeficit additionally prefers the loadpoint with the larger gap | ||
| // between vehicle soc and its limit soc among loadpoints of the same priority. | ||
| PriorityDeficit PriorityStrategy = "deficit" | ||
| ) | ||
|
|
||
| // String implements Stringer | ||
| func (s PriorityStrategy) String() string { | ||
| if s == PriorityStatic { | ||
|
andig marked this conversation as resolved.
Outdated
|
||
| return "static" | ||
| } | ||
| return string(s) | ||
| } | ||
|
|
||
| // PriorityStrategyString converts a string to PriorityStrategy | ||
| func PriorityStrategyString(s string) (PriorityStrategy, error) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pattern here is to use enumer and textmarshaler instead of handrolling these. |
||
| switch strings.ToLower(strings.TrimSpace(s)) { | ||
| case "", "static": | ||
| return PriorityStatic, nil | ||
| case string(PrioritySoc): | ||
| return PrioritySoc, nil | ||
| case string(PriorityDeficit): | ||
| return PriorityDeficit, nil | ||
| default: | ||
| return PriorityStatic, fmt.Errorf("invalid priority strategy: %s", s) | ||
| } | ||
| } | ||
|
|
||
| // PriorityBasis determines whether a priority strategy ranks loadpoints by soc | ||
| // percentage or by absolute energy (kWh). Valid values are percent and energy. | ||
| type PriorityBasis string | ||
|
|
||
| // Priority bases | ||
| const ( | ||
| // PriorityBasisPercent ranks the priority strategy in soc-% (default), so a | ||
| // percentage gap is compared regardless of battery capacity. | ||
| PriorityBasisPercent PriorityBasis = "" | ||
| // PriorityBasisEnergy ranks the priority strategy by absolute energy (kWh) by | ||
| // scaling the soc-% gap with the vehicle capacity, so a smaller battery is not | ||
| // over-prioritized just because its percentage is lower. Falls back to percent | ||
| // when the vehicle capacity is unknown. | ||
| PriorityBasisEnergy PriorityBasis = "energy" | ||
| ) | ||
|
|
||
| // String implements Stringer | ||
| func (b PriorityBasis) String() string { | ||
| if b == PriorityBasisPercent { | ||
| return "percent" | ||
| } | ||
| return string(b) | ||
| } | ||
|
|
||
| // PriorityBasisString converts a string to PriorityBasis | ||
| func PriorityBasisString(s string) (PriorityBasis, error) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dito- pls keep consistency with rest of the codebase |
||
| switch strings.ToLower(strings.TrimSpace(s)) { | ||
| case "", "percent", "percentage", "soc": | ||
| return PriorityBasisPercent, nil | ||
| case string(PriorityBasisEnergy), "absolute", "kwh": | ||
| return PriorityBasisEnergy, nil | ||
| default: | ||
| return PriorityBasisPercent, fmt.Errorf("invalid priority basis: %s", s) | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming: what makes this "static"? Isn't it really first come, first serve? Or maybe "none"?