flobz / psa_car_controller

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

ZeroDivisionError: float division by zero #648

Closed sod75 closed 11 months ago

sod75 commented 11 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. what command did you use nothing
  2. when the bug append ? after update to (docker) v3.0.12
  3. Does it persist after restarting the program? Yes
  4. Does it persist after recreate config by going to http://server_address:port/config? Yes

Config file Give the anonymize content of the config file

[General]
currency = €
# define format for data export, can be csv or xlsx
export_format = csv
# minimum trip length in km so it's added to stats and map in website
minimum trip length = 1
# for future use
length unit = km
export format = csv
[Electricity config]
# price by kw/h
day price = 0.35
night price
# ex: 22h30
night hour start
# ex: 6h00
night hour end
dc charge price
high speed dc charge price
# minimum power in kW that should be delivered during a charge so it can be considered as a high speed charger
high speed dc charge threshold
charger efficiency = 0.8942

Environment (please complete the following information):

appears every 2 minuntes Additional context Add any other context about the problem here.

2023-10-31 18:56:42,437 :: INFO :: new position recorded for VF3M4DGxxx
2023-10-31 18:56:42,440 :: 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 43, in dto_to_battery_curve
    speed_in_kw_from_km(battery_curves_dto[end - 1])
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/battery_charge_curve.py", line 32, in speed_in_kw_from_km
    speed = battery_curve_dto.rate / km_by_kw
ZeroDivisionError: float division by zero
2023-10-31 18:56:55,338 :: INFO :: 192.168.0.91 - - [31/Oct/2023 18:56:55] "GET /get_vehicleinfo/VF3M4DGZ
sod75 commented 11 months ago

@flobz did the database layout change from 3.0.10 yo 3.0.12? I deleted my info.db and with an empty one the error is now gone.