flobz / psa_car_controller

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

Exception on /get_vehicleinfo/###VIN### #167

Closed gavin0987 closed 3 years ago

gavin0987 commented 3 years ago

It seems the Vauxhall API is not providing the mileage for my Vauxhall Corsa-E to this application.

When HomeAssistant calls psa_car_controller to get_vehicleinfo there is no data returned and I see a stack trace printed in the docker logs.

Exception on /get_vehicleinfo/VXxxxxxxxxxxxxx [GET]
PSAController    | Traceback (most recent call last):
PSAController    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
PSAController    |     response = self.full_dispatch_request()
PSAController    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
PSAController    |     rv = self.handle_user_exception(e)
PSAController    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
PSAController    |     rv = self.dispatch_request()
PSAController    |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
PSAController    |     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
PSAController    |   File "/psa_car_controller/web/views.py", line 133, in get_vehicle_info
PSAController    |     response=json.dumps(CONFIG.myp.get_vehicle_info(vin, from_cache).to_dict(), default=str),
PSAController    |   File "/psa_car_controller/my_psacc.py", line 156, in get_vehicle_info
PSAController    |     self.record_info(car)
PSAController    |   File "/psa_car_controller/my_psacc.py", line 459, in record_info
PSAController    |     **mileage = car.status.timed_odometer.mileage**
PSAController    | **AttributeError: 'NoneType' object has no attribute 'mileage'**

To Reproduce Steps to reproduce the behavior:

  1. what command did you use Standard setup using latest docker build, behavior seems to be cause by upstream issue.
  2. when the bug append ? Bug has always existed for me
  3. Does it persist after restarting the program? Yes

Config file Give the anonymize content of the config file

Environment (please complete the following information):

Additional context I have been working around the issue by editing the my_pssacc.py file and changing:

_mileage = car.status.timedodometer.mileage to mileage = 0

I am happy to run any tests as needed, just shout!

flobz commented 3 years ago

Thanks for reporting, I never had this problem. I will catch this error in next version.

gavin0987 commented 3 years ago

Thanks, I am not entirely sure why the mileage is not coming through in the first place. The MyVauxhall app shows the cars mileage so would expect the API call to return the value to your code.

flobz commented 3 years ago

fix in develop branch