-
Notifications
You must be signed in to change notification settings - Fork 8
test(sungrow): confirm the battery before commanding it #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ftw": patch | ||
| --- | ||
|
|
||
| The Sungrow zero-power test confirms the battery before commanding, matching the driver's refusal to write EMS registers a string inverter does not implement. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,12 +56,26 @@ func TestSungrowZeroBatteryCommandForcesIdle(t *testing.T) { | |
| env := NewHostEnv("sungrow", tel).WithModbus(modbus) | ||
| env.BatteryCapacityWh = 9600 | ||
|
|
||
| // Answer register 4999 as an SH8.0RT so the driver classifies this as a | ||
| // hybrid. Sungrow ships two families behind one driver and an SG string | ||
| // inverter implements none of 13049-13051, so the driver refuses a battery | ||
| // setpoint until the model has named itself a hybrid or a battery register | ||
| // has answered. Without this the mock answers 0 everywhere, detection | ||
| // settles on "unknown", and the refusal is correct rather than a bug -- | ||
| // see srcfl/device-drivers#40 and #43. | ||
| modbus.regs[4999] = 0x0E0E | ||
|
|
||
| d, err := NewLuaDriver("../../../drivers/sungrow.lua", env) | ||
| if err != nil { | ||
| t.Fatalf("load: %v", err) | ||
| } | ||
| defer d.Cleanup() | ||
|
|
||
| if _, err := d.Poll(context.Background()); err != nil { | ||
| t.Fatalf("poll: %v", err) | ||
| } | ||
|
Comment on lines
+74
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Remove this poll or add a separate test for the original scenario: in the reviewed Useful? React with 👍 / 👎. |
||
| modbus.resetWrites() | ||
|
|
||
| cmd, _ := json.Marshal(map[string]any{"action": "battery", "power_w": 0}) | ||
| if err := d.Command(context.Background(), cmd); err != nil { | ||
| t.Fatalf("command: %v", err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this release entry or land the corresponding driver behavior in the same change. This commit modifies only the test, while
drivers/sungrow.luastill gates confirmation withpower_w ~= 0, so an unconfirmed zero-power command continues writing registers 13049–13051. Consuming this changeset would bump the package and publish a changelog claim that is not true of the released artifact.Useful? React with 👍 / 👎.