charger/custom: support api.PhaseGetter via optional "getphases" field (#32756)
This commit is contained in:
parent
5d518717d7
commit
29b0eabeed
1 changed files with 14 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue