Repository navigation
Conversation
Update on Battery hold/charge/normal Use DC side control instead of active power values, because not supported on older SI (Gen 11 und 12) Should also work on Gen 13 - not tested
- Fix calculation - added discharge value
verified SI Gen 13 compatibility with SMA Modbus SPEC MODBUS-HTML_SI44M-80H-13_34003R_V10
removed unnecessary stuff
convert value in charge section to int after mulf which results in float
There was a problem hiding this comment.
Hey - I've found 6 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="121" />
<code_context>
+ source: modbus
+ {{- include "modbus" . | indent 12 }}
+ register:
+ address: 40799 # Maximale Batterieentladeleistung
+ type: writemultiple
+ decode: uint32
</code_context>
<issue_to_address>
**Battery keeps discharging in hold**
When hold is requested while the battery is discharging, the sequence disables the setpoint before zeroing register 40799, leaving the previous discharge limit active in the meantime. If an earlier write fails, the sequence stops before 40799 is zeroed, so the battery continues discharging.
Write zero to register 40799 before disabling the setpoint or applying the other hold-sequence writes.
</issue_to_address>
### Comment 2
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="129" />
<code_context>
set:
- source: const
- value: -{{ .maxchargepower }} # Wirkleistungsvorgabe
+ value: -{{ mulf .maxchargepower 1.1 | int64 }} # Wirkleistungsvorgabe ---> SunnyIsland berechnet intern die max Wirkleistung via Ampere.
+ # im Falle des SI6.0H-1x sind das exemplarisch 20A, also 4600/230 = 20A. Der Max Wert ergibt sich aus dem maximal zulässigen
+ # Spannung im Europäischen Stromnetz (+/-10%), somit kann auf den Max Wert des Batteriestellers 10% aufgeschlagen werden
</code_context>
<issue_to_address>
**Charge boost remains DC-capped**
When the charge mode is entered after normal mode and the Sunny Island enforces 40795 as its maximum battery charging power, when charge follows normal, register 40795 remains capped at `maxchargepower`, while the charge case only raises the AC setpoint at 40149 to 1.1 times that value and does not update 40795. The stated 10% increase therefore cannot increase the battery charging power above the configured cap.
If the 10% increase is intended to raise battery charging power, update the 40795 limit consistently in charge mode, while preserving any required battery safety limit.
Also at `templates/definition/meter/sma-si-modbus.yaml:76`.
</issue_to_address>
### Comment 3
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="22" />
<code_context>
- preset: battery-params
- - name: maxchargepower
+ - name: maxchargepower # could be read at 40189 on on SI Gen 11, 12 and 13. Don't know how to implemet it here yet
+ default: 4200
+ required: true
+ - name: maxdischargepower # async value, depending on battery, could also be read at 40191 on SI Gen 11, 12 and 13. Don't know how to implemet it here yet
</code_context>
<issue_to_address>
**Higher-rated batteries are capped**
When a Sunny Island supports more than 4200 W and the user leaves the defaults unchanged, normal mode writes the 4200 W defaults to the battery charge and discharge limits, capping the unit at 4200 W.
Choose defaults that do not impose a 4200 W cap on higher-rated units.
Also at `templates/definition/meter/sma-si-modbus.yaml:25`, `templates/definition/meter/sma-si-modbus.yaml:76-86`.
</issue_to_address>
### Comment 4
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="129-133" />
<code_context>
+ value: -{{ mulf .maxchargepower 1.1 | int64 }} # Wirkleistungsvorgabe ---> SunnyIsland berechnet intern die max Wirkleistung via Ampere.
</code_context>
<issue_to_address>
**Charge explanation exceeds comment limit**
When maintainers read the charge-case setpoint comment, the five-line explanation attached to the charge setpoint exceeds the repository’s one-to-two-line limit for comments, making the rationale harder to scan and maintain.
Condense the rationale to at most two lines while retaining the key constraint.
</issue_to_address>
### Comment 5
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="63" />
<code_context>
switch:
- case: 1 # normal
set:
- source: const
- value: 803 # inaktiv (Ina)
</code_context>
<issue_to_address>
**issue (review_instructions):** This duplicates the `set` key and makes the sequence structure ambiguous.
There are two consecutive `set:` keys under `source: sequence` here. Please remove the extra key so the template has an unambiguous structure.
<details>
<summary>Review instructions:</summary>
**Path patterns:** `templates/**/*.yaml`
**Instructions:**
Verify that the changes comply to the rules defined in templates/README.md. Also check consistence (wording) with other files inside templates directory.
[Edit this rule](https://app.sourcery.ai/dashboard/review-settings?connection=github&owner=evcc-io&from_surface=github_bot&intent=review_rules&activeTab=review-rules&rule=74ec55f5-149d-4827-9376-6dccef98d305)
</details>
</issue_to_address>
### Comment 6
<location path="templates/definition/meter/sma-si-modbus.yaml" line_range="21" />
<code_context>
de: Der ModbusTCP Server muss aktiviert sein.
- preset: battery-params
- - name: maxchargepower
+ - name: maxchargepower # could be read at 40189 on on SI Gen 11, 12 and 13. Don't know how to implemet it here yet
+ default: 4200
+ required: true
</code_context>
<issue_to_address>
**nitpick (review_instructions):** The new comment contains the typo “implemet.”
Please correct the spelling to “implement” to keep the added wording consistent and polished.
<details>
<summary>Review instructions:</summary>
**Path patterns:** `templates/**/*.yaml`
**Instructions:**
Also check consistence (wording) with other files inside templates directory.
[Edit this rule](https://app.sourcery.ai/dashboard/review-settings?connection=github&owner=evcc-io&from_surface=github_bot&intent=review_rules&activeTab=review-rules&rule=74ec55f5-149d-4827-9376-6dccef98d305)
</details>
</issue_to_address>|
There's already #36038? |
|
Ah, closed the other one. |
premultiply
left a comment
There was a problem hiding this comment.
Thanks for this and for testing on real hardware. The core idea (803 + blocking discharge via 40799 = 0 in hold) is right and fixes #36020. A few things need to change before merge:
-
normalnow hard-limits the device to the evcc params. Previouslynormalonly wrote 803. Now it also writesmaxchargepower/maxdischargepowerinto 40795/40799. These params are meant as optimizer planning values, so users who set them conservatively will now be throttled. On top of that, the newmaxdischargepowerdefault of 4200 W silently caps discharge on SI 8.0H or clusters. Innormal, please restore the device limits (e.g. the device maximum from 40189/40191) or a non-restricting value instead. -
Please drop the
mulf .maxchargepower 1.1change from this PR. It is unrelated to the fix.maxchargepoweris the power the user asked for, so the template shouldn't add 10% on top. Users who want more can raise the value. It is also inconsistent: 40795 stays atmaxchargepowerfromnormal/hold, so if the SI honours it in setpoint mode the boost has no effect. The five-line comment is also too long for our comment style. If you want to pursue this, please open a separate PR. -
Write
40799 = 0first inhold. Writing 803 first means the SI can briefly discharge aftercharge, and if a later write fails, discharge stays open. -
Are 40795/40799 volatile on the Sunny Island? The watchdog rewrites the whole sequence every
timeout/2(30s). This is documented as fine for SBS, but please confirm these registers aren't persisted to EEPROM on the SI. -
chargeleaves 40799/40795 as they were. Afterhold,40799 = 0sticks duringcharge. Probably harmless for forced charging, but the state now depends on the previous mode. Please make that a deliberate choice. -
Cleanup:
- Remove the comments on the params ("Don't know how to implemet it here yet", "on on").
required: trueis redundant with a default.- Please rename the PR to e.g.
SMA Sunny Island: allow PV charging in hold mode.
The red UI check is unrelated: tests pass, and make ui fails with git describe because there are no tags on the fork branch.
🤖 Generated with Claude Code
|
Please also use the descriptions from the SMA Modbus Profile documentation. |
Linked issuesChecked at commit 3a6ba1e #36020 Optimizer issue: SMA Sunny Island stops charging in battery hold mode · 1 of 1 met
|
- added helper function to read 40189/40191 and write it back to 40795/40799 - added same function to reset discharge if change from hold to charge - cleanup code
changed sequence of register writing
Updated to read device maximum from 40189/40191 and write to 40795/40799
Change the order of writing the register and removed the mulf and restored origin.
Same for SI, the register are volatile and will be fall back to default after 180sec. Working with it für more than 6 years in an older project for ioBroker.
As mentioned not really necessary, will be fall back to default after 180s but added for clean exit.
Done
Done |
|
Tested the change for 2 days now. Works perfect on my Hardware |
|
@premultiply good to merge? |
There was a problem hiding this comment.
🔵 Needs a closer look
Firmware-dependent register sequencing, hold/charge/normal transitions, and watchdog recovery still require hardware validation, while Sunny Island generation 13 compatibility remains untested.
No open issues 🎉
What changed in this PR
Updates the SMA Sunny Island meter integration so battery hold mode blocks discharge while allowing PV charging, addressing #36020 without relying on registers unsupported by older generations.
Changes:
- Replaces hold mode’s fixed 0 W setpoint with battery power limits.
- Restores power limits when returning to normal or forced-charge operation.
- Requires explicit maximum charge and discharge power values, with device-based prefilling in the UI. Existing YAML configurations must supply both values.
| File | Description |
|---|---|
templates/definition/meter/sma-si-modbus.yaml |
Updates battery-mode register writes and adds required power-limit parameters with device read services. |
🤖 Generated with GitHub Copilot
Review effort: Balanced
…t int-only go sources
|
Pls make the params explicit |
fixes #36020, depends on #36548
Hold should stop discharging but let PV keep charging the battery. The Sunny Island template set a fixed 0 W setpoint (40149 WSpt = 0, 40151 = 802) instead, which also stopped PV charging and sent the surplus to the grid.
Hold now uses the BMS power limits instead of an active power setpoint, since the approach from #36038 is not supported on older Sunny Island generations.
maxchargepower/maxdischargepowerare optional and suggested from the device maximum (40189 BatConv.WMaxCha / 40191 BatConv.WMaxDsch) in the UI. Left empty, the device maximum is used via thefallbackplugin (Plugin: add fallback source for device-provided defaults #36548), read once, both for the optimizer and for the registers above. The previous 4200 W default is gonesma-modbus.tplinclude, also used by the other SMA battery templates in SMA: device maximum as battery limit fallback, unify SBS and hybrid battery control #36469. Includes the plugin commit from Plugin: add fallback source for device-provided defaults #36548 until that is mergedTested on SI 6.0H-11 and 6.0H-12. Not tested on generation 13.
TODO
🤖 Generated with Claude Code