EEBus: state the limit to a controllable system on connect (#32491)
This commit is contained in:
parent
dc1ac7c6dd
commit
4a878838e7
6 changed files with 175 additions and 13 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue