From 10332edf0a36d6f9a661c1ef8b4d07ebd7bd33ae Mon Sep 17 00:00:00 2001 From: Dylan Moreland <79415431+elffjs@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:44:21 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20return=20-0.0=20for=20Tesla=20p?= =?UTF-8?q?ower=20(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/tesla/vehicle-convert-funcs_gen.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/tesla/vehicle-convert-funcs_gen.go b/pkg/tesla/vehicle-convert-funcs_gen.go index 754b6c4..4ffb21b 100644 --- a/pkg/tesla/vehicle-convert-funcs_gen.go +++ b/pkg/tesla/vehicle-convert-funcs_gen.go @@ -89,7 +89,12 @@ func ToPowertrainTractionBatteryChargingIsCharging0(originalDoc []byte, val stri // Vehicle.Powertrain.TractionBattery.CurrentPower: Current electrical energy flowing in/out of battery. Positive = Energy flowing in to battery, e.g. during charging. Negative = Energy flowing out of battery, e.g. during driving. // Unit: 'W' func ToPowertrainTractionBatteryCurrentPower0(originalDoc []byte, val float64) (float64, error) { - return -kilowattsToWatts(val), nil + res := -kilowattsToWatts(val) + if res == 0 { + // Avoid returning -0.0 in the common case where val is 0.0. + return 0, nil + } + return res, nil } // ToPowertrainTractionBatteryStateOfChargeCurrent0 converts data from field 'charge_state.battery_level' of type float64 to 'Vehicle.Powertrain.TractionBattery.StateOfCharge.Current' of type float64.