Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 error : division by zero #437

Closed
thennart opened this issue Nov 25, 2022 · 8 comments
Closed

500 error : division by zero #437

thennart opened this issue Nov 25, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@thennart
Copy link

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):

  • OS: NUC Intel (windows 10) with docker desktop
  • Peugeot 3008 Hybrid
  • Application version : master

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
Copy link

rimrul commented Nov 25, 2022

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
Copy link

zoic21 commented Dec 8, 2022

Hello,

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

@thennart
Copy link
Author

thennart commented Dec 9, 2022

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.

@flobz flobz added the bug Something isn't working label Jan 2, 2023
flobz added a commit that referenced this issue Jan 2, 2023
flobz added a commit that referenced this issue Jan 2, 2023
@thennart
Copy link
Author

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

@flobz
Copy link
Owner

flobz commented Jan 13, 2023

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

@flobz flobz closed this as completed Jan 13, 2023
@marc6901
Copy link

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
Copy link
Author

thennart commented Jan 22, 2023 via email

@Ilpo55
Copy link
Contributor

Ilpo55 commented Feb 9, 2023

Same here.

flobz added a commit that referenced this issue Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants