EEBus: add controlbox test (#28908)

This commit is contained in:
andig 2026-06-23 11:50:36 +02:00 • committed by GitHub
parent bc55f913f9
commit 0d9189d64c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 9 deletions

View file

@ -117,10 +117,12 @@ func (h *controlbox) OnLPCEvent(ski string, device spineapi.DeviceRemoteInterfac
switch event {
case lpc.UseCaseSupportUpdate:
h.registerRemoteEntity(entity, event)
// case lpc.DataUpdateLimit:
// if currentLimit, err := h.uclpc.ConsumptionLimit(entity); err == nil {
// fmt.Println("New consumption limit received", currentLimit.Value, "W")
// }
if currentLimit, err := h.uclpc.ConsumptionLimit(entity); err == nil {
fmt.Println("New consumption limit received", currentLimit.Value, "W")
}
case lpc.DataUpdateLimit:
h.registerRemoteEntity(entity, event)
default:
fmt.Println("lpc:", event)
}

View file

@ -19,8 +19,6 @@ import (
const remotePort = 9001
func TestEEBus(t *testing.T) {
t.Skip()
util.LogLevel("error", map[string]string{"eebus": "trace"})
certificate, err := cert.CreateCertificate("Demo", "Demo", "DE", "Demo-Server-01")
@ -46,7 +44,7 @@ func TestEEBus(t *testing.T) {
box, err := createControlbox(t.Context(), server.Ski(), remotePort)
require.NoError(t, err, "controlbox")
eventC := make(chan api.EventType, 1)
eventC := make(chan api.EventType, 16)
box.remoteEventC = eventC
hems, err := hems.NewEEBus(t.Context(), box.ski, eebus.Limits{}, nil, nil, time.Second)
@ -54,9 +52,13 @@ func TestEEBus(t *testing.T) {
go hems.Run()
<-eventC
// wait for DataUpdateLimit which signals that limit descriptions and data are available
require.Eventually(t, func() bool {
return len(box.remoteEntity(lpc.DataUpdateLimit)) > 0
}, 30*time.Second, 100*time.Millisecond, "waiting for lpc.DataUpdateLimit")
t.Log(box.remoteEntities)
srvEntity := box.remoteEntity(lpc.UseCaseSupportUpdate)[0]
srvEntity := box.remoteEntity(lpc.DataUpdateLimit)[0]
_, err = box.uclpc.WriteConsumptionLimit(srvEntity, ucapi.LoadLimit{
IsActive: true,