MBMD: add returnEnergy support (#30514)

This commit is contained in:
premultiply 2026-06-04 23:32:02 +02:00 • committed by GitHub
parent 380416e3e1
commit aaed8c24a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 56 additions and 0 deletions

View file

@ -35,6 +35,7 @@ func NewMbmdFromConfig(ctx context.Context, other map[string]any) (api.Meter, er
batterySocLimits `mapstructure:",squash"`
modbus.Settings `mapstructure:",squash"`
Power, Energy, Soc string
ReturnEnergy string
Currents []string
Voltages []string
Powers []string
@ -103,6 +104,15 @@ func NewMbmdFromConfig(ctx context.Context, other map[string]any) (api.Meter, er
implement.Has(m, implement.MeterEnergy(totalEnergy))
}
// decorate return energy
if cc.ReturnEnergy != "" {
returnEnergy, err := mbmd.deviceOp(ops, cc.ReturnEnergy)
if err != nil {
return nil, fmt.Errorf("invalid measurement for returnenergy: %s", cc.ReturnEnergy)
}
implement.Has(m, implement.MeterReturnEnergy(returnEnergy))
}
// decorate soc
if cc.Soc != "" {
soc, err := mbmd.deviceOp(ops, cc.Soc)