EEBus: state the limit to a controllable system on connect (#32491)

This commit is contained in:
andig 2026-08-03 18:13:37 +02:00 • committed by GitHub
parent dc1ac7c6dd
commit 4a878838e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 175 additions and 13 deletions

View file

@ -6,9 +6,11 @@ import (
"log"
"time"
"github.com/cenkalti/backoff/v4"
eebusapi "github.com/enbility/eebus-go/api"
"github.com/enbility/spine-go/model"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
)
func WrapError(err error) error {
@ -45,6 +47,19 @@ func Await(write func(func(model.ResultDataType, model.MsgCounterType)) (*model.
}
}
// limitTimeout keeps the retries inside the 60s the spec grants the Energy Guard.
const limitTimeout = 50 * time.Second
// AssertLimit states the current limit to a newly available Controllable System
// ([LPC-913]/[LPP-913]). Blocks while retrying- the CS ignores writes that do not
// follow a heartbeat and may reject them while still in state "init".
func AssertLimit(log *util.Logger, write func() error) {
bo := backoff.NewExponentialBackOff(backoff.WithMaxElapsedTime(limitTimeout))
if err := backoff.Retry(write, bo); err != nil {
log.DEBUG.Printf("assert limit: %v", err)
}
}
func LogEntities(log *log.Logger, actor string, uc eebusapi.UseCaseInterface) {
ss := uc.RemoteEntitiesScenarios()
if len(ss) > 0 {