Huawei SUN2000: add curtail#28549
Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
curtailMeter.Curtailed, you returnval < m.nominalLimiteven whencurtailedGreturns an error; consider short‑circuiting and returningfalse, erron error to avoid exposing a potentially misleading curtailed state when the underlying read failed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `curtailMeter.Curtailed`, you return `val < m.nominalLimit` even when `curtailedG` returns an error; consider short‑circuiting and returning `false, err` on error to avoid exposing a potentially misleading curtailed state when the underlying read failed.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Any updates on this? |
|
Currently on hold until the topic receives more love... |
|
Never saw this PR. Whats missing? |
|
Ah I see. ATM we only have static curtailment limit, i.e. curtail to 0. There are no urgent plans to change this. @premultiply do we need to change that? |
|
See initial posting. Curtailment via templating hasn‘t yet been merged. |
|
Yeah- that's because that PR is not scoped. |
|
Curtailment has been merged |
|
OK. Will check today. |
a962576 to
6dcd527
Compare
|
Done. There are still open questions from my side though, see initial posting. |
Whats the question?
Because the current API doesn't allow that.
What received limited power? |
Shall I set the mode as well? Mode
It may not be necessary at the moment because only 0 and 100% is supported. But what if we want to set something in between? We'll need the wattage passed via FNN controlbox to be converted to % of the maximum inverter power, no? |
7b3d816 to
e032796
Compare
|
I updated and cleaned up the branch. I am still getting the error: So do I need the |
Do we need a |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
BoolSetterhandling forconstPluginwithtyp == "int"always callsset(0), which both ignores the incoming boolean value and overwrites the configured integer, so it likely won’t apply the intended curtailment percentage; consider either mappingtrue/falseto meaningful integer values or using a different mechanism that preserves the configuredValue. curtailpercentdefaults to0and is directly written (scaled) to register47418, which effectively enforces 0% feed-in when curtailment is enabled; if that’s not intended, consider using a sentinel (e.g. unset/nil) or explicit validation to distinguish “no curtailment configured” from “explicit 0% feed-in”.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `BoolSetter` handling for `constPlugin` with `typ == "int"` always calls `set(0)`, which both ignores the incoming boolean value and overwrites the configured integer, so it likely won’t apply the intended curtailment percentage; consider either mapping `true/false` to meaningful integer values or using a different mechanism that preserves the configured `Value`.
- `curtailpercent` defaults to `0` and is directly written (scaled) to register `47418`, which effectively enforces 0% feed-in when curtailment is enabled; if that’s not intended, consider using a sentinel (e.g. unset/nil) or explicit validation to distinguish “no curtailment configured” from “explicit 0% feed-in”.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
It is probably important for evcc not to perform a |
| type constPlugin struct { | ||
| ctx context.Context | ||
| str string | ||
| typ string |
There was a problem hiding this comment.
the const changes need be reverted, was a bad idea
There was a problem hiding this comment.
The template does not work with the reverted const changes!
[main ] FATAL 2026/05/19 18:38:46 meter [sun2000] cannot create meter 'sun2000': cannot create meter type 'template:huawei-sun2000': cannot create meter type 'custom': curtail: strconv.ParseBool: parsing "7": invalid syntax
There was a problem hiding this comment.
As commented on the other pr: use convert to switch to int setter.
There was a problem hiding this comment.
Can't figure this out. Could use some more help.
There was a problem hiding this comment.
You need convert with bool2int, same as the other PR
Co-authored-by: andig <cpuidle@gmail.com>
This reverts commit 91949d8.


a.k.a. zero feed-in / § 9 EEG
Huawei API
Active power control register definition
Testing
Open Questions
47416(Maximum Feed Grid Power (kW))?TODOs
Active power control modevia Modbus (7c8034f)curtail(true|false)Plugins: add ifelse plugin #29988evcc meter sun2000 --curtail 1evcc meter sun2000 --curtail 0