flobz / psa_car_controller

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

ZeroDivisionError: float division by zero #601

Closed GeraldPape closed 8 months ago

GeraldPape commented 11 months ago
2023-08-08 15:00:44,210 :: ERROR :: Can't find country for None None
2023-08-08 15:00:44,211 :: WARNING :: Using country of origin : AT (wrong co2 when traveling abroad)
2023-08-08 15:00:44,216 :: 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

To Reproduce Steps to reproduce the behavior:

  1. In the UI clicked on charge

Config file Give the anonymize content of the config file

{
    "abrp": {
        "abrp_enable_vin": [],
        "token": ""
    },
    "client_id": "some guid",
    "client_secret": "some secret",
    "co2_signal_api": null,
    "country_code": "AT",
    "customer_id": "AC-some accountid",
    "proxies": {
        "http": "",
        "https": ""
    },
    "realm": "clientsB2CCitroen",
    "refresh_token": "some guid",
    "remote_refresh_token": "some token",
    "weather_api": null
}

Environment (please complete the following information): Docker

Additional context Add any other context about the problem here.

GeraldPape commented 11 months ago

In the charging db table entries are here, but the UI shows nothing. grafik

grafik

GeraldPape commented 11 months ago

afzer initializing the app completely new:

2023-08-08 21:55:31,742 :: ERROR :: Exception on /get_vehicleinfo/xxxxxxxxx[GET]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/views.py", line 146, in get_vehicle_info
    response=json.dumps(APP.myp.get_vehicle_info(vin, from_cache).to_dict(), default=str),
  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-08-08 21:55:31,745 :: INFO :: 10.0.0.76 - - [08/Aug/2023 21:55:31] "GET /get_vehicleinfo/xxxxxxxxxxx HTTP/1.1" 500 -
papageigit commented 11 months ago

This happened to my install (which ran fine for months) on Home Assistant since a week ago aswell. Even after reinstalling, the same errors got thrown again in the console and it would not get information anymore.

Eventually I reinstalled it on a seperate VM using Docker and it works fine now..

SabatoArdolino commented 10 months ago

Hi to all I receive the same error from 1 week. I've installed the addon by HACS. did you fix the issue ?

SabatoArdolino commented 8 months ago

In the charging db table entries are here, but the UI shows nothing. grafik

grafik

Where do you find this information ?