skodaconnect / homeassistant-skodaconnect

Skoda Connect - A home assistant plugin to add integration with your car
Apache License 2.0
230 stars 28 forks source link

v1.0.40-RC5: vehicle-status api returns 404 #39

Closed NNMavy closed 3 years ago

NNMavy commented 3 years ago

Describe the bug Recently I started seeing 404 errors being generated by the skodaconnect integration. After some investigation it appears that the api has changed and as a result the car is detected as a smartlink vehicle however the api it is trying to access does not exist.

Al though the integration does continue start up there is no actual data being retrieved so all the sensors stay unavailable.

Debug logs 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Token for smartlink verified OK. 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Going to call vehicle updates 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Adding vin for data refresh 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Calling update function for all vehicles 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.vehicle] API endpoints: {'vehicle_status': {'active': True}} 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] HTTP GET "https://api.connect.skoda-auto.cz/api/v1/vehicle-status/*vin" 2021-06-08 10:59:48 ERROR (MainThread) [skodaconnect.connection] Got unhandled error from server: 404 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Going to call vehicle updates 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Adding vin for data refresh 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] Calling update function for all vehicles 2021-06-08 10:59:48 DEBUG (MainThread) [skodaconnect.connection] HTTP GET "https://api.connect.skoda-auto.cz/api/v1/vehicle-status/vin" 2021-06-08 10:59:48 ERROR (MainThread) [skodaconnect.connection] Got unhandled error from server: 404 2021-06-08 10:59:48 DEBUG (MainThread) [custom_components.skodaconnect] Updating data from Skoda Connect 2021-06-08 10:59:48 INFO (MainThread) [custom_components.skodaconnect] Adding data for VIN: vin* from Skoda Connect

Installation:

Farfar commented 3 years ago

Does latest non-RC release work?

NNMavy commented 3 years ago

v1.0.38 does appear to work yes. I upgraded to the RC because of another issue I was having, I just don't remember which one.

EDIT: I just got reminded why I upgraded to the RC. Current release is spamming the logs with errors about failed login after a while.

2021-06-08 20:00:25 WARNING (MainThread) [skodaconnect.connection] Login for skoda account failed! 2021-06-08 20:00:25 WARNING (MainThread) [skodaconnect.connection] Could not update information: Login for skoda account failed 2021-06-08 20:00:25 WARNING (MainThread) [custom_components.skodaconnect] Could not query update from Skoda Connect

Farfar commented 3 years ago

OK. With RC5, can you enable debug logging and response debug and upload info here please? You could also clone the latest library and run the example code. Open the examply.py and add your username/password combo, change printresponse to true and run with python3.

The interesting line is the one that looks like this (taken from debug for my car): DEBUG:skodaconnect.connection:Request for "https://api.connect.skoda-auto.cz/api/v2/garage/vehicles" returned with status code [200], response: [{'id': '', 'vin': '', 'lastUpdatedAt': '2021-06-09T11:13:29.961518Z', 'specification': {'title': 'ŠKODA Superb Combi', 'brand': 'ŠKODA', 'model': 'Superb', 'body': 'Combi', 'systemCode': 'SUP.COM iV L&K TS 115/1.4 A6F', 'systemModelId': '3V55XC', 'engine': {'type': 'TSI iV', 'powerInKW': 160, 'capacityInLiters': 1.4}, 'gearbox': {'type': 'A6F'}, 'trimLevel': 'L&K', 'manufacturingDate': '2020-01-31', 'devicePlatform': 'MBB_ODP'}, 'connectivities': [{'type': 'ONLINE'}], 'capabilities': [{'id': 'DCS', 'statuses': []}]}]

The most interesting would be the "connectivities" value.

NNMavy commented 3 years ago

The library returns the following:

DEBUG:skodaconnect.connection:Request for "https://api.connect.skoda-auto.cz/api/v2/garage/vehicles" returned with status code [200], response: [{'id': 'id', 'vin': 'vin', 'lastUpdatedAt': '2021-06-09T11:57:20.314623Z', 'specification': {'title': 'ŠKODA Karoq', 'brand': 'ŠKODA', 'model': 'Karoq', 'body': 'SUV', 'systemCode': 'KAROQ SPO TS 110/1.5 A7F', 'systemModelId': 'NU7RND', 'engine': {'type': 'TSI', 'powerInKW': 110, 'capacityInLiters': 1.5}, 'gearbox': {'type': 'A7F'}, 'trimLevel': 'Sportline', 'manufacturingDate': '2020-03-13', 'devicePlatform': 'MBB'}, 'connectivities': [{'type': 'INCAR', 'detail': {'incar': {'state': 'ACTIVATED'}}}, {'type': 'ONLINE'}], 'capabilities': [{'id': 'DCS', 'statuses': []}]}]

Farfar commented 3 years ago

The library returns the following:

DEBUG:skodaconnect.connection:Request for "https://api.connect.skoda-auto.cz/api/v2/garage/vehicles" returned with status code [200], response: [{'id': 'id', 'vin': 'vin', 'lastUpdatedAt': '2021-06-09T11:57:20.314623Z', 'specification': {'title': 'ŠKODA Karoq', 'brand': 'ŠKODA', 'model': 'Karoq', 'body': 'SUV', 'systemCode': 'KAROQ SPO TS 110/1.5 A7F', 'systemModelId': 'NU7RND', 'engine': {'type': 'TSI', 'powerInKW': 110, 'capacityInLiters': 1.5}, 'gearbox': {'type': 'A7F'}, 'trimLevel': 'Sportline', 'manufacturingDate': '2020-03-13', 'devicePlatform': 'MBB'}, 'connectivities': [{'type': 'INCAR', 'detail': {'incar': {'state': 'ACTIVATED'}}}, {'type': 'ONLINE'}], 'capabilities': [{'id': 'DCS', 'statuses': []}]}]

Thanks, I see the issue now. I haven't seen a vehicle with both Smartlink capabilities and Skoda Connect. The way the library works right now it expects only one capability and will use the first match, Smartlink (INCAR) in your case. I have rewritten the code and it should work with your car now, please pull the latest commit and test with example code. If it works I will release a new RC.

NNMavy commented 3 years ago

The latest commit works. I wonder if my car has both capabilities because I have asked Skoda to enable the remote locking functionality.

Farfar commented 3 years ago

The latest commit works. I wonder if my car has both capabilities because I have asked Skoda to enable the remote locking functionality.

That's good to know, then the fix works and I can commit new RC release. The remote locking is part of Connect service, Smartlink is for cars without online services at all, your phone when connected to the car extracts the data and uploads to the servers.

NNMavy commented 3 years ago

I was not aware my car supported smartlink, learn something new everyday.

I look forward to testing the new RC.

Farfar commented 3 years ago

Closing this issue since it should be fixed in later releases