charger/custom: support api.PhaseGetter via optional "getphases" field (#32756)

This commit is contained in:
PsychoPat 2026-08-12 08:05:39 +02:00 • committed by GitHub
parent 5d518717d7
commit 29b0eabeed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,7 +33,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]any) (api.C
embed `mapstructure:",squash"`
Status, Enable, Enabled, MaxCurrent plugin.Config
MaxCurrentMillis *plugin.Config
Identify, Phases1p3p *plugin.Config
Identify, Phases1p3p, GetPhases *plugin.Config
Wakeup *plugin.Config
Soc *plugin.Config
LimitSoc *plugin.Config
@ -100,6 +100,19 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]any) (api.C
}))
}
// decorate phase getter
if cc.GetPhases != nil {
getPhasesG, err := cc.GetPhases.IntGetter(ctx)
if err != nil {
return nil, fmt.Errorf("getphases: %w", err)
}
implement.Has(c, implement.PhaseGetter(func() (int, error) {
v, err := getPhasesG()
return int(v), err
}))
}
// decorate identifier
identify, err := cc.Identify.StringGetter(ctx)
if err != nil {