Ocpp: allow specifying measurements to remove (#16185)
This commit is contained in:
parent
3d64200448
commit
69f6bd1a47
1 changed files with 8 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/remotetrigger"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/smartcharging"
|
||||
"github.com/lorenzodonini/ocpp-go/ocpp1.6/types"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
const desiredMeasurands = "Power.Active.Import,Energy.Active.Import.Register,Current.Import,Voltage,Current.Offered,Power.Offered,SoC"
|
||||
|
|
@ -57,7 +58,13 @@ func (cp *CP) Setup(meterValues string, meterInterval time.Duration) error {
|
|||
if opt.Readonly {
|
||||
meterValuesSampledDataMaxLength = 0
|
||||
}
|
||||
cp.meterValuesSample = *opt.Value
|
||||
if remove, ok := strings.CutPrefix(meterValues, "-"); ok {
|
||||
// remove offending measurands
|
||||
cp.meterValuesSample = strings.Join(lo.Without(strings.Split(*opt.Value, ","), strings.Split(remove, ",")...), ",")
|
||||
meterValues = ""
|
||||
} else {
|
||||
cp.meterValuesSample = *opt.Value
|
||||
}
|
||||
|
||||
case strings.EqualFold(opt.Key, KeyMeterValuesSampledDataMaxLength):
|
||||
if val, err := strconv.Atoi(*opt.Value); err == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue