Skip to content

OpenEMS: align maxchargepower configuration (BC)#25766

Merged
andig merged 1 commit intoevcc-io:masterfrom
iseeberg79:fix/maxchargepower
Dec 23, 2025
Merged

OpenEMS: align maxchargepower configuration (BC)#25766
andig merged 1 commit intoevcc-io:masterfrom
iseeberg79:fix/maxchargepower

Conversation

@iseeberg79
Copy link
Copy Markdown
Contributor

@iseeberg79 iseeberg79 commented Dec 2, 2025

Removed default value for maxchargepower as it is unkown.

The parameter maxchargepower is not to be required because to control a battery is optional. As it should not be empty if battery control is configured, error handling is required.

Works for UI-based and yaml-based configurations.

Required: set a proper value for maxchargepower to make grid charging available (default was 4200, higher values possible)

- remove default
- error handling if not set
@andig andig added devices Specific device support enhancement New feature or request labels Dec 2, 2025
@iseeberg79
Copy link
Copy Markdown
Contributor Author

@deadrabbit87 @Bockhorn-IT could you do a review?

Copy link
Copy Markdown
Contributor

@Bockhorn-IT Bockhorn-IT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to remove the default value in the rest template.

Looks good for me and your explanation makes sense.

@github-actions github-actions Bot added the stale Outdated and ready to close label Dec 9, 2025
@iseeberg79 iseeberg79 changed the title OpenEMS: align maxchargepower configuration OpenEMS: align maxchargepower configuration (BC) Dec 10, 2025
@iseeberg79 iseeberg79 marked this pull request as ready for review December 10, 2025 06:07
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Using {{- if .maxchargepower }} will treat 0 as false, so a configured value of 0 will hit the ErrNotAvailable branch; if 0 is a meaningful value, switch to an explicit nil/empty check (e.g., test for existence in .params or use a sentinel) instead of relying on truthiness.
  • The new source: error / error: ErrNotAvailable branch changes behavior when maxchargepower is omitted; confirm this error type is the intended one for UI/yaml validation and consider aligning it with any existing validation pattern used for other optional-but-required-when-feature-enabled parameters.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `{{- if .maxchargepower }}` will treat `0` as false, so a configured value of `0` will hit the `ErrNotAvailable` branch; if `0` is a meaningful value, switch to an explicit nil/empty check (e.g., test for existence in `.params` or use a sentinel) instead of relying on truthiness.
- The new `source: error` / `error: ErrNotAvailable` branch changes behavior when `maxchargepower` is omitted; confirm this error type is the intended one for UI/yaml validation and consider aligning it with any existing validation pattern used for other optional-but-required-when-feature-enabled parameters.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions github-actions Bot removed the stale Outdated and ready to close label Dec 10, 2025
@andig
Copy link
Copy Markdown
Member

andig commented Dec 10, 2025

The parameter maxchargepower is not to be required because to control a battery is optional. As it should not be empty if battery control is configured, error handling is required.

It seems we're inconsistent across templates there, see #25929. Not sure which policy we want but we should honor consistency. When finished, #25932 should also enforce required params for yaml-based config.

@iseeberg79
Copy link
Copy Markdown
Contributor Author

iseeberg79 commented Dec 10, 2025

Yes, we should. There is as well the sum-of-devices approach different here I am not very happy with.

You directed recently not defaulting to "unknown" values. Let's clarify and fix.

I tried to be consistent with latest Plenticore changes here. I am personally not very happy not to use default values here. I think the default values are making things easier.

Required is not true because of a "cascade" of parameters.

Actually this change would be okay. Having default values I'd like to prefer.

@github-actions github-actions Bot added the stale Outdated and ready to close label Dec 17, 2025
@github-actions github-actions Bot closed this Dec 22, 2025
@andig
Copy link
Copy Markdown
Member

andig commented Dec 22, 2025

@iseeberg79 can't we simply require this value? #25932 will raise any errors from missing value.

@andig andig reopened this Dec 22, 2025
@github-actions github-actions Bot removed the stale Outdated and ready to close label Dec 22, 2025
@iseeberg79
Copy link
Copy Markdown
Contributor Author

Thanks for re-opening

no, not in this case as the template should work without battery (ess0) provided and requires no chargepower in this case.

We could of course require a battery device but this is a breaking change and is inconsistent from my point of view because of the summarized value approach.

What about to redesign the template, require the devices instead of using summarized values? Then maxchargepower should be initially a required value and evcc shows any producer or battery defined.

Personally I'd like to go for the changes this PR introduces.

@andig
Copy link
Copy Markdown
Member

andig commented Dec 22, 2025

We could of course require a battery device but this is a breaking change and is inconsistent from my point of view because of the summarized value approach.

If should only be required for usage battery of course

@iseeberg79
Copy link
Copy Markdown
Contributor Author

Of course, but still remains

@andig andig merged commit 9eba0f7 into evcc-io:master Dec 23, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants