tesladdicts / testatus

Python suite to access the Tesla JSON API, pollers and log via the API, parse the log, rpc, etc
MIT License
12 stars 2 forks source link

error in tesla_parser.py since change in API version 10 #8

Closed pmendes closed 4 years ago

pmendes commented 4 years ago

Starting from August 27 2020, the tesla API version 10 is including "vehicle_config": null when the car state is "asleep". This then results in an error in the tesla_parselib.py :

  File "build/bdist.linux-x86_64/egg/tesla_parselib.py", line 48, in __init__
  File "build/bdist.linux-x86_64/egg/tesla_parselib.py", line 121, in _jget
TypeError: argument of type 'NoneType' is not iterable

lines 48-54 would get the details of the vehicle_config, but _jget cannot deal with a null object.

A simple resolution would be to include lines 48-54 of tesla_parselib.py inside an if self.state != "asleep": which I will be trying out

pmendes commented 4 years ago

Unfortunately the fix above does not work. It turns out that when the vehicle goes online it still issues a record with "state": "online" but which still has "vehicle_config" = null So checking the state is not enough. I think this probably needs to be fixed in _jget instead.

pmendes commented 4 years ago

I confirm the problem is the presence of "vehicle_config": null the files can be fixed by filtering with sed sed 's/\"vehicle_config\": null,//' original-file > new-file then running tesla-parser.py new-file runs without problems. This can be used as a temporary fix until we fix the bug

SethRobertson commented 4 years ago

Just pushed a fix that works for me. No need to sed any files.