From 82a3f643a633824c7a364d4dd24a9d47584cb5a4 Mon Sep 17 00:00:00 2001 From: andig Date: Tue, 7 Jul 2026 19:34:08 +0200 Subject: [PATCH] EEBus: fix GridGuard entity type removed from LPC/LPP (#31568) --- go.mod | 2 +- go.sum | 4 +-- server/eebus/test/gridguard_test.go | 54 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 server/eebus/test/gridguard_test.go diff --git a/go.mod b/go.mod index 48a6c5f0b..de0e55414 100644 --- a/go.mod +++ b/go.mod @@ -262,4 +262,4 @@ replace github.com/grid-x/modbus => github.com/evcc-io/modbus v0.0.0-20250501165 replace github.com/lorenzodonini/ocpp-go => github.com/evcc-io/ocpp-go v0.0.0-20251212212612-b7f92ee0443b -replace github.com/enbility/eebus-go => github.com/evcc-io/eebus-go v0.0.0-20260707085304-6939a96c368f +replace github.com/enbility/eebus-go => github.com/evcc-io/eebus-go v0.0.0-20260707170747-eb60ff7e2025 diff --git a/go.sum b/go.sum index 434696057..25a64eb06 100644 --- a/go.sum +++ b/go.sum @@ -144,8 +144,8 @@ github.com/enbility/spine-go v0.7.1-0.20260629113257-b3bcc643f323 h1:bLsMlyRamUg github.com/enbility/spine-go v0.7.1-0.20260629113257-b3bcc643f323/go.mod h1:ddWZU5BQGyzRGF20Z7rUKFFzbCp+cfu9mZgYtOMW/fM= github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 h1:XOYvxKtT1oxT37w/5oEiRLuPbm9FuJPt3fiYhX0h8Po= github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6/go.mod h1:BszP9qFV14mPXgyIREbgIdQtWxbAj3OKqvK02HihMoM= -github.com/evcc-io/eebus-go v0.0.0-20260707085304-6939a96c368f h1:4qTrzQ1yUs0FrTMXf9OTSIshdFi7Blq5TErrsF7Karg= -github.com/evcc-io/eebus-go v0.0.0-20260707085304-6939a96c368f/go.mod h1:L1nBEy/dBASQRoz/9JF7KEmqFdnXHLbZqDpxiA0ezr4= +github.com/evcc-io/eebus-go v0.0.0-20260707170747-eb60ff7e2025 h1:hXZTTduvtyv4NxC6T4tBsKOniqC7f5nhvaIxQBvmyjg= +github.com/evcc-io/eebus-go v0.0.0-20260707170747-eb60ff7e2025/go.mod h1:L1nBEy/dBASQRoz/9JF7KEmqFdnXHLbZqDpxiA0ezr4= github.com/evcc-io/modbus v0.0.0-20250501165638-8b6f1fbdb7ea h1:F6eyC8V8wvc3ranlsR4coAls+OPBkVvxyX0a2VqdlPc= github.com/evcc-io/modbus v0.0.0-20250501165638-8b6f1fbdb7ea/go.mod h1:swrNGAVgI1r/3d/sEKE7qgujdRR9aHVPYKyc3gvpVTc= github.com/evcc-io/ocpp-go v0.0.0-20251212212612-b7f92ee0443b h1:5vFr7wOwoi5ylybUnxxBk1U3FRF2+3Sf0sKx8thxw18= diff --git a/server/eebus/test/gridguard_test.go b/server/eebus/test/gridguard_test.go new file mode 100644 index 000000000..37bbbf188 --- /dev/null +++ b/server/eebus/test/gridguard_test.go @@ -0,0 +1,54 @@ +package eebus + +import ( + "testing" + "time" + + "github.com/enbility/ship-go/cert" + "github.com/evcc-io/evcc/hems/eebus" + hems "github.com/evcc-io/evcc/hems/eebus" + server "github.com/evcc-io/evcc/server/eebus" + "github.com/evcc-io/evcc/util" + "github.com/stretchr/testify/require" +) + +// TestControlBoxGridGuardHeartbeat covers issue #31561: a real ControlBox exposes LPC/LPP +// only on a GridGuard entity; if eebus-go's cs/lpc validEntityTypes ever drops it again, the heartbeat subscription silently never happens and the LPC failsafe eventually trips. +func TestControlBoxGridGuardHeartbeat(t *testing.T) { + util.LogLevel("error", map[string]string{"eebus": "trace"}) + + // tear down a server instance left over from other tests in this package + if inst, err := server.Instance(); err == nil { + inst.Shutdown() + } + + certificate, err := cert.CreateCertificate("Demo", "Demo", "DE", "Demo-GridGuard-01") + require.NoError(t, err, "certificate") + + public, private, err := server.GetX509KeyPair(certificate) + require.NoError(t, err, "decode certificate") + + _, err = server.NewServer(server.Config{ + Port: freePort(t), + Certificate: server.Certificate{ + Public: public, + Private: private, + }, + }) + require.NoError(t, err, "server") + + inst, err := server.Instance() + require.NoError(t, err, "instance") + + // the controlbox test double, like a real ControlBox, only exposes GridGuard + box, err := createControlbox(t.Context(), inst.Ski(), freePort(t)) + require.NoError(t, err, "controlbox") + + // no hems.Run(): the run loop applies limits via the nil site and is not needed here + _, err = hems.NewEEBus(t.Context(), box.ski, eebus.Limits{}, nil, nil, time.Second) + require.NoError(t, err, "hems") + + require.Eventually(t, inst.ControllableSystem().CsLPCInterface.IsHeartbeatWithinDuration, + 10*time.Second, 100*time.Millisecond, + "CsLPC never subscribed to the ControlBox's GridGuard heartbeat") +}