Fronius Gen24: add PV curtailment support - #32823
Merged
Merged
Conversation
Implements api.Curtailer via SunSpec model 123 (WMaxLimPct/WMaxLim_Ena), the same mechanism already used by sunspec-inverter-curtailable.yaml. Confirmed working on real GEN24 hardware over Modbus TCP.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In the
curtail.setswitch cases you have nestedsetkeys (e.g.set: { source: const, ... set: { source: sunspec ... } }), which is likely invalid for this template DSL; consider separating these into a proper sequence of steps rather than nestingsetinside anothersetblock. - The
curtailedscript returns anintderived from afloatlimit; if the surrounding system expects a float percentage like other PV limit fields, it may be safer to keep this as a float to avoid unintended truncation or type mismatches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the `curtail.set` switch cases you have nested `set` keys (e.g. `set: { source: const, ... set: { source: sunspec ... } }`), which is likely invalid for this template DSL; consider separating these into a proper sequence of steps rather than nesting `set` inside another `set` block.
- The `curtailed` script returns an `int` derived from a `float` limit; if the surrounding system expects a float percentage like other PV limit fields, it may be safer to keep this as a float to avoid unintended truncation or type mismatches.
## Individual Comments
### Comment 1
<location path="templates/definition/meter/fronius-gen24.yaml" line_range="180-188" />
<code_context>
+ value: 123:WMaxLimPct
+ - source: switch
+ switch:
+ - case: 100 # Uncurtailed
+ set:
+ source: const
+ value: 0 # Limit disabled
+ set:
+ source: sunspec
+ uri: {{ joinHostPort .host .port }}
+ id: 1
+ value: 123:WMaxLim_Ena
+ default:
+ source: const
</code_context>
<issue_to_address>
**issue (bug_risk):** The nested `set` under the `case: 100` branch is structured differently from the `default` branch and is likely not parsed as intended.
In the `case: 100` branch you currently have a nested `set`:
```yaml
- case: 100 # Uncurtailed
set:
source: const
value: 0 # Limit disabled
set:
source: sunspec
uri: {{ joinHostPort .host .port }}
id: 1
value: 123:WMaxLim_Ena
```
whereas the `default` branch uses a single `set` block:
```yaml
default:
source: const
value: 1 # Limit enabled
set:
source: sunspec
uri: {{ joinHostPort .host .port }}
id: 1
value: 123:WMaxLim_Ena
```
Because the `case: 100` structure differs from the expected pattern, the Sunspec write there may not execute. Please align the `case: 100` structure with the `default` branch (const source + one `set` block) so both paths behave consistently.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary
curtail/curtailedto thefronius-gen24.yamlPV usage block, implementingapi.Curtailervia SunSpec model 123 (WMaxLimPct/WMaxLim_Ena) — the same mechanism already used bysunspec-inverter-curtailable.yaml."curtail"to the template'scapabilitieslist.Test plan
Verified against real GEN24 hardware (12 kW Symo GEN24 Plus) over Modbus TCP:
WMaxLimPct,WMaxLim_Ena)