flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
391 stars 199 forks source link

500 error : division by zero #437

Closed thennart closed 1 year ago

thennart commented 1 year ago

Describe the bug 500 error while trying to get data. In log, I have a "division by zero" error. Workaround is to delete database (but I lose datas). After several days or weeks, error randomly reappear. I tried to identified the data in database but I didn't notice anything wrong.

To Reproduce Steps to reproduce the behavior: Call API "get_vehicleinfo" or go to dashboard

Config file Give the anonymize content of the config file

Environment (please complete the following information):

Log :

2022-11-25 10:47:23,166 :: INFO :: 172.18.0.1 - - [25/Nov/2022 10:47:23] "GET /get_vehicleinfo/xxxxxxxxxxx HTTP/1.1" 500 2022-11-25 10:45:43,836 :: ERROR :: refresh_vehicle_info: Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py", line 125, in __refresh_vehicle_info self.get_vehicle_info(car.vin) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py", line 108, in get_vehicle_info self.record_info(car) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py", line 202, in record_info Charging.record_charging(car, charging_status, charge_date, level, latitude, longitude, self.country_code, File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 96, in record_charging Charging.update_chargings(conn, last_charge, car) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 52, in update_chargings Charging.set_charge_price(charge, conn, car) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 36, in set_charge_price battery_curves = Charging.get_battery_curve(conn, charge, car) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/charging.py", line 31, in get_battery_curve battery_curves = BatteryChargeCurve.dto_to_battery_curve(car, charge, battery_curves_dto) File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/battery_charge_curve.py", line 26, in dto_to_battery_curve km_by_kw = 0.8 * battery_curves_dto[-1].autonomy / battery_capacity ZeroDivisionError: float division by zero

rimrul commented 1 year ago

File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/battery_charge_curve.py", line 26, in dto_to_battery_curve km_by_kw = 0.8 * battery_curves_dto[-1].autonomy / battery_capacity

Sounds like it thinks your car has a battery capacity of 0, for some reason.

zoic21 commented 1 year ago

Hello,

Same for me, I don't known why....

thennart commented 1 year ago

Once again, same error ... need to delete db ... @rimrul yes I saw error could come from battery capacity but a test should be added in order to avoid this kind of exception.

thennart commented 1 year ago

Hello Just saw that a commit was done in order to fix the issue but the fix isn't available on docker image. :-(

flobz commented 1 year ago

It's available in the docker image with the v3.0.8 tag.

marc6901 commented 1 year ago

Hi, the issue is still there: the same make and model of the car, the same error and the new version of the docker file (v3.0.8)

thennart commented 1 year ago

Same here

Le dim. 22 janv. 2023 à 17:26, Marcel @.***> a écrit :

Hi, the issue is still there: the same make and model of the car, the same error and the new version of the docker file (v3.0.8)

— Reply to this email directly, view it on GitHub https://github.com/flobz/psa_car_controller/issues/437#issuecomment-1399536098, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDP2WAESSJCKZC6DLXLB43WTVNTPANCNFSM6AAAAAASLEPPZU . You are receiving this because you authored the thread.Message ID: @.***>

Ilpo55 commented 1 year ago

Same here.