Skip to content

Sungrow-hybrid - Add curtailing - #33210

Open
harmendp wants to merge 7 commits into
evcc-io:masterfrom
harmendp:feature/sungrow_add_curtailing
Open

Sungrow-hybrid - Add curtailing#33210
harmendp wants to merge 7 commits into
evcc-io:masterfrom
harmendp:feature/sungrow_add_curtailing

Conversation

@harmendp

Copy link
Copy Markdown
Contributor

Sungrow: add EEG §9 curtailment support

What
Adds feed-in curtailment (capabilities: ["curtail"]) to the sungrow-hybrid PV meter template, so Sungrow SH-series hybrid inverters can be used as a curtailable device with evcc's External Limit (§14a/§9) feature — same mechanism already used by sunspec-inverter.yaml.

Implementation notes

Uses Feed-in Limitation (register 13087) to enable/disable the limiter, and Feed-in Limitation Value (register 13074, absolute Watts) rather than Feed-in Limitation Ratio (register 13088, 0.1% units) to express the target level. The percentage-based ratio register was only added to Sungrow's Modbus protocol in V1.1.7 (May 2025) and isn't reliably available across firmware versions; the Watt-based register has been present much longer and proved more broadly compatible in testing. The Watt target is derived from the existing maxacpower param (maxacpower * curtail / 100).
maxacpower is now a required param, since curtail/curtailed depend on it directly for the percentage↔Watt conversion.
Follows the same enable/disable convention Sungrow uses elsewhere in this template (0xAA/170 = enable, 0x55/85 = disable), and the same 100%-is-uncurtailed convention evcc's other curtailable templates use.

Testing

Verified against a Sungrow SH4.0RS (WiNet-S) — write and read round-trip correctly with the Watt-based approach.
Not yet tested against SH-RT/SH-T/MG-series units; feedback from owners of those models welcome before merge.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="templates/definition/meter/sungrow-hybrid.yaml" line_range="136-162" />
<code_context>
+          ena := 170 // 0xAA - enable limitation
</code_context>
<issue_to_address>
**issue (bug_risk):** If the second Modbus write to `watts` fails after the first write succeeds, the inverter remains in the newly enabled state while retaining its previous feed-in limit, so the requested curtailment is not applied and the device can export above the requested cap.

**Triggers:** When changing or enabling curtailment and the feed-in limitation value write fails.

**Suggested fix:** On failure of the value write, retry the operation or explicitly restore the previous switch state instead of leaving the limiter enabled with a stale value.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the change writes a feed-in power limit to the inverter, so an incorrect calculation or register interpretation could leave the device curtailed and cause generation to be lost until someone corrects the setting. Reverting the software would not undo the register write or recover production that was missed.

Blocking findings: templates/definition/meter/sungrow-hybrid.yaml:162


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.

Comment on lines +136 to +162
ena := 170 // 0xAA - enable limitation
if curtail == 100 {
ena = 85 // 0x55 - disable limitation
}
ena
out:
- name: ena
type: int
config:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 13086 # Feed-in Limitation switch (doc 13087), 0xAA enable / 0x55 disable
type: writesingle
decode: uint16
- source: go
script: |
watts := curtail * {{ .maxacpower }} / 100
watts
out:
- name: watts
type: int
config:
source: modbus
{{- include "modbus" . | indent 12 }}
register:
address: 13073 # Feed-in Limitation Value (doc 13074), 1W resolution

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): If the second Modbus write to watts fails after the first write succeeds, the inverter remains in the newly enabled state while retaining its previous feed-in limit, so the requested curtailment is not applied and the device can export above the requested cap.

Triggers: When changing or enabling curtailment and the feed-in limitation value write fails.

Suggested fix: On failure of the value write, retry the operation or explicitly restore the previous switch state instead of leaving the limiter enabled with a stale value.

@github-actions github-actions Bot added devices Specific device support enhancement New feature or request labels Aug 26, 2026
@andig

andig commented Aug 27, 2026

Copy link
Copy Markdown
Member

/cc @CiNcH83

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.

2 participants