Ocpp: compatibility enhancements (#15479)
This commit is contained in:
parent
d74fbd383c
commit
3e24c9103c
1 changed files with 14 additions and 11 deletions
|
|
@ -42,7 +42,7 @@ type OCPP struct {
|
|||
|
||||
const (
|
||||
defaultIdTag = "evcc" // RemoteStartTransaction only
|
||||
desiredMeasurands = "Energy.Active.Import.Register,Power.Active.Import,SoC,Current.Offered,Power.Offered,Current.Import,Voltage"
|
||||
desiredMeasurands = "Power.Active.Import,Energy.Active.Import.Register,SoC,Current.Offered,Power.Offered,Current.Import,Voltage"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -179,13 +179,10 @@ func NewOCPP(id string, connector int, idtag string,
|
|||
// fix timing issue in EVBox when switching OCPP protocol version
|
||||
time.Sleep(time.Second)
|
||||
|
||||
var (
|
||||
rc = make(chan error, 1)
|
||||
var rc = make(chan error, 1)
|
||||
|
||||
// If a key value is defined as a CSL, it MAY be accompanied with a [KeyName]MaxLength key, indicating the
|
||||
// max length of the CSL in items. If this key is not set, a safe value of 1 (one) item SHOULD be assumed.
|
||||
meterValuesSampledDataMaxLength = 1
|
||||
)
|
||||
meterValuesSampledData := ""
|
||||
meterValuesSampledDataMaxLength := len(strings.Split(desiredMeasurands, ","))
|
||||
|
||||
err = ocpp.Instance().GetConfiguration(cp.ID(), func(resp *core.GetConfigurationConfirmation, err error) {
|
||||
if err == nil {
|
||||
|
|
@ -216,6 +213,12 @@ func NewOCPP(id string, connector int, idtag string,
|
|||
c.chargingProfileId = val
|
||||
}
|
||||
|
||||
case ocpp.KeyMeterValuesSampledData:
|
||||
if opt.Readonly {
|
||||
meterValuesSampledDataMaxLength = 0
|
||||
}
|
||||
meterValuesSampledData = *opt.Value
|
||||
|
||||
case ocpp.KeyMeterValuesSampledDataMaxLength:
|
||||
if val, err := strconv.Atoi(*opt.Value); err == nil {
|
||||
meterValuesSampledDataMaxLength = val
|
||||
|
|
@ -229,7 +232,7 @@ func NewOCPP(id string, connector int, idtag string,
|
|||
|
||||
case ocpp.KeySupportedFeatureProfiles:
|
||||
if !c.hasProperty(*opt.Value, smartcharging.ProfileName) {
|
||||
err = fmt.Errorf("the mandatory SmartCharging profile is not supported")
|
||||
c.log.WARN.Printf("the required SmartCharging feature profile is not indicated as supported")
|
||||
}
|
||||
c.hasRemoteTriggerFeature = c.hasProperty(*opt.Value, remotetrigger.ProfileName)
|
||||
|
||||
|
|
@ -281,12 +284,12 @@ func NewOCPP(id string, connector int, idtag string,
|
|||
|
||||
// configure measurands
|
||||
if meterValues != "" {
|
||||
if err := c.configure(ocpp.KeyMeterValuesSampledData, meterValues); err != nil {
|
||||
return nil, err
|
||||
if err := c.configure(ocpp.KeyMeterValuesSampledData, meterValues); err == nil {
|
||||
meterValuesSampledData = meterValues
|
||||
}
|
||||
}
|
||||
|
||||
c.meterValuesSample = meterValues
|
||||
c.meterValuesSample = meterValuesSampledData
|
||||
|
||||
// trigger initial meter values
|
||||
if c.hasRemoteTriggerFeature {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue