lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
262 stars 125 forks source link

SetChargingProfile - Validation issue with ChargingProfilePurposeChargePointMaxProfile #152

Open olga2323 opened 1 year ago

olga2323 commented 1 year ago

Dear all,

when using 1.6 and SetChargingProfile like so:

    cProfile.ChargingProfileId = 1
    cProfile.StackLevel = 0
    cProfile.ChargingProfilePurpose = types.ChargingProfilePurposeChargePointMaxProfile
    cProfile.ChargingProfileKind = types.ChargingProfileKindAbsolute

    cProfile.ChargingSchedule = types.NewChargingSchedule(types.ChargingRateUnitAmperes,
        types.ChargingSchedulePeriod{
            StartPeriod:  0,
            Limit:        float64(limit),
            NumberPhases: &phases,
        })

    err := cs.SetChargingProfile(chargePointName, func(confirmation *smartcharging.SetChargingProfileConfirmation, err error) {
               // some error handling/logging ....
    }, 0, &cProfile)
    if err != nil {
        logrus.WithFields(logrus.Fields{
            "ChargePoint": chargePointName,
        }).Errorf("SetChargingProfile NOT sent %v", err)
        return false
    }

returns an error when using types.ChargingProfilePurposeChargePointMaxProfile, with ChargingProfilePurposeTxDefaultProfile it works ok. I could not spot the issue but removing the validation chargingProfilePurpose brings success, also using ChargingProfilePurposeTxDefaultProfile works.

Lets me know if I can bring more info.

Thanks for all the work.

lorenzodonini commented 1 year ago

Hello,

I just tested this and it didn't throw any validation errors at all:

func test(chargePointID string) {
    cProfile := types.ChargingProfile{}
    cProfile.ChargingProfileId = 1
    cProfile.StackLevel = 0
    cProfile.ChargingProfilePurpose = types.ChargingProfilePurposeChargePointMaxProfile
    cProfile.ChargingProfileKind = types.ChargingProfileKindAbsolute
    phases := 3
    cProfile.ChargingSchedule = types.NewChargingSchedule(types.ChargingRateUnitAmperes,
        types.ChargingSchedulePeriod{
            StartPeriod:  0,
            Limit:        float64(10),
            NumberPhases: &phases,
        })
    err := centralSystem.SetChargingProfile(chargePointID, func(confirmation *smartcharging.SetChargingProfileConfirmation, err error) {
        if err != nil {
            logDefault(chargePointID, smartcharging.SetChargingProfileFeatureName).Errorf("error on request: %v", err)
        } else {
            logDefault(chargePointID, smartcharging.SetChargingProfileFeatureName).Infof("status: %v", confirmation.Status)
        }
    }, 0, &cProfile)
    if err != nil {
        fmt.Println(err)
    }
}

Is the error being returned on CSMS side or by the charging station? Also, can you confirm what error is being returned specifically?