Heating: add (limit)temp to custom charger (#29270)

This commit is contained in:
Alexandre JARDON 2026-04-21 18:32:13 +02:00 • committed by GitHub
parent 06f4d904d7
commit aea44089ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,6 +38,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]any) (api.C
Soc *plugin.Config
LimitSoc *plugin.Config
Tos bool
measurement.Temperature `mapstructure:",squash"` // optional, for heating devices
measurement.Energy `mapstructure:",squash"` // optional
meter.Phases `mapstructure:",squash"` // optional
}
@ -114,18 +115,31 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]any) (api.C
}
}
// decorate soc
// decorate soc; for heating devices (api.Heating feature), the soc slot holds
// temperature in °C — fall back to temp getter when no soc getter is configured.
soc, err := cc.Soc.FloatGetter(ctx)
if err != nil {
return nil, fmt.Errorf("soc: %w", err)
}
// decorate limitsoc
// decorate limitsoc; similarly, fall back to limittemp getter when no limitsoc is configured.
limitsoc, err := cc.LimitSoc.IntGetter(ctx)
if err != nil {
return nil, fmt.Errorf("limitsoc: %w", err)
}
// heating fallbacks
temp, limitTemp, err := cc.Temperature.Configure(ctx)
if err != nil {
return nil, err
}
if soc == nil && temp != nil {
soc = temp
}
if limitsoc == nil && limitTemp != nil {
limitsoc = limitTemp
}
// decorate measurements
powerG, energyG, err := cc.Energy.Configure(ctx)
if err != nil {