srwalter / garmin-tesla

ConnectIQ widget for Tesla vehicle control
32 stars 17 forks source link

Widget crashes on all Garmin devices #42

Open bdo opened 9 months ago

bdo commented 9 months ago

Hi @srwalter,

First and foremost, I am a big fan of your Garmin widget! Thanks for all your hard work on this!!!

Since this summer, the Tesla API has evolved they removed the display_name from the vehicle_data response. The unofficial documentation was update to reflect this following issue #728.

Because of Tesla's change, the widget crashes shortly after connecting, when trying to get the vehicle_data.

When debugging, this is what we see in the debug console:

Error: Unhandled Exception
Exception: UnexpectedTypeException: Expected Number/Float/Boolean/Long/Double, given null
Stack: 
  - setText() at 704b03c0.mb:5530 0x300043fd 
  - onUpdate() at /Users/bdoncieu/projects/garmin-tesla/source/MainView.mc:115 0x1000122f 

Encountered app crash.

The fix is simple: use the vehicle_name under the vehicle_state subsection of the /vehicle_data response.