Custom charger: add optional finish timer (#29600)

This commit is contained in:
Copilot 2026-05-04 17:47:25 +02:00 • committed by GitHub
parent 0178d32302
commit 975caea21c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 92 additions and 11 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"
reg "github.com/evcc-io/evcc/util/registry"
)
@ -163,3 +164,24 @@ func (c *Config) BytesSetter(ctx context.Context, param string) (func([]byte) er
return prov.BytesSetter(param)
}
// TimeGetter returns a getter that parses the plugin value as an estimated finish time.
// The value may be an RFC3339 timestamp, a Go duration string, or a numeric number of seconds.
func (c *Config) TimeGetter(ctx context.Context) (func() (time.Time, error), error) {
if c == nil {
return nil, nil
}
stringG, err := c.StringGetter(ctx)
if err != nil {
return nil, err
}
return func() (time.Time, error) {
s, err := stringG()
if err != nil {
return time.Time{}, err
}
return parseRelativeTime(s)
}, nil
}