lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
275 stars 126 forks source link

OCPP 2.0.1 - Sampled Value validation is failing when 0 value is sent #157

Closed alexandrepasc closed 1 year ago

alexandrepasc commented 1 year ago

When sending the meter value to the central system and some of the values in the sampled value are zero, the framework is failing to send the request.

The central system doesn't receive the request and it returns the error: Key: 'Call.Payload.MeterValue[0].SampledValue[1].Value' Error:Field validation for 'Value' failed on the 'required' tag

The transaction request is: {Started 2022-12-09 23:09:59.722428058 +0000 WET m=+11.004372863 CablePluggedIn 0 false <nil> <nil> <nil> {nwjH6PvYQh Charging <nil> <nil>} <nil> 0xc000222360 [{2022-12-09 23:09:59.722416663 +0000 WET m=+11.004361473 [{500 Current.Import Outlet <nil> 0xa09c60} {0.1 Energy.Active.Import.Register Outlet <nil> 0xa09c80} {179267 Power.Active.Import Outlet <nil> 0xa09ca0} {230 Voltage Outlet <nil> 0xa09cc0}]}]}

I'm new to the OCPP and still reading the OCPP 2.0.1 specifications, but I don't see any restrictions on the specifications to the value being zero.

Can someone help me?

And tks in advance.

FYI: Nice job on this repo @lorenzodonini .

lorenzodonini commented 1 year ago

Hey @alexandrepasc and thanks!

This is actuallty a duplicate of https://github.com/lorenzodonini/ocpp-go/issues/151.

I'll take care of it asap and make the value not required. This is technically not correct, but at least it prevents breaking changes (such as making Value a pointer type) for the time being.

alexandrepasc commented 1 year ago

Tks for the reply and sorry for the duplication.