From 29b0eabeed8dde4ff05ec9220b0a40dce4b58d29 Mon Sep 17 00:00:00 2001 From: PsychoPat <90036588+PatrickScheidl@users.noreply.github.com> Date: Wed, 12 Aug 2026 08:05:39 +0200 Subject: [PATCH] charger/custom: support api.PhaseGetter via optional "getphases" field (#32756) --- charger/charger.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/charger/charger.go b/charger/charger.go index 7d7fce0b2..dbaaec800 100644 --- a/charger/charger.go +++ b/charger/charger.go @@ -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 {