Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sungrow-zero-test-confirms-the-battery.md
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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not release behavior that only changed in a test

Drop this release entry or land the corresponding driver behavior in the same change. This commit modifies only the test, while drivers/sungrow.lua still gates confirmation with power_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 👍 / 👎.

14 changes: 14 additions & 0 deletions go/internal/drivers/sungrow_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the pre-poll zero-command regression test

Remove this poll or add a separate test for the original scenario: in the reviewed drivers/sungrow.lua, driver_command deliberately exempts power_w == 0 from battery confirmation because that command can arrive before the first poll. By identifying the inverter and polling first, this test would remain green if that exemption were accidentally removed, leaving fresh or not-yet-polled drivers unable to receive the zero-power stop; the original pre-poll test passes against this tree.

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)
Expand Down