remygrandin / Tuskla

Tesla control app for fitbit smartwatch
MIT License
5 stars 2 forks source link

stuck at "Got request: WakeUP" #1

Open jaybee808 opened 4 years ago

jaybee808 commented 4 years ago

Hi, i am stuck at the Screen Waking up your tesla. the token and everything is OK (All good) but it still doesn't work. any tipps for debugging?

remygrandin commented 4 years ago

Hi, Sorry for that, I experience this issue too on a weekly basis. It seem the watch app has trouble "waking up" the companion app on the phone. If you go into the app setting in the fitbit app, it should be woken up and work. The only debugging I can suggest right now is importing it into fitbit studio to have the debug console output.

jaybee808 commented 4 years ago

Hi, i am already working with the console ;) i am using a versa 2.

Output from console: [12:18:11]App Started companion/index.js:30,9 [12:18:11]Got request : CheckToken companion/TeslaAPI.js:90,3 [12:18:11]Checking Token in local storage ... companion/TeslaAPI.js:94,5 [12:18:11] Token not found, regenerating it ... [HOST][12:18:11]Launch complete - durations: foregrounding(1269ms), first paint(253ms), total(1527ms). companion/TeslaAPI.js:101,3 [12:18:13] Token available : qts-e31xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx companion/TeslaAPI.js:103,3 [12:18:13] Checking Token expiracy ... companion/TeslaAPI.js:104,3 [12:18:13] Token expire at : Tue Oct 20 2020 12:18:12 GMT+0200 (CEST) companion/TeslaAPI.js:115,3 [12:18:13] Token expiration validity OK companion/TeslaAPI.js:117,3 [12:18:13] Testing Token validity ... companion/TeslaAPI.js:130,3 [12:18:13] Token All good app/index.js:71,3 [12:18:13]Got data : {"data":{"type":"response","response":"InitOk"}} app/index.js:86,9 [12:18:13]Got response message : InitOk companion/index.js:30,9 [12:18:13]Got request : WakeUp app/index.js:71,3 [12:18:14]Got data : {"data":{"type":"error","error":{}}} app/index.js:104,1 [12:18:14]Unknow type received : error

remygrandin commented 4 years ago

Hmm, weird. I will make some additional test on my side. You can try enabling the debug on the telsa api call by add-in a true boolean as an extra argument to display I. The log the full api response

jaybee808 commented 4 years ago

sorry, i'm new to this ;)... where in the code do i have to add the argument? maybe you can give an expample? Thanks ;)

remygrandin commented 4 years ago

Of course :-) In the TeslaAPI file (https://github.com/remygrandin/Tuskla/blob/master/companion/TeslaAPI.js) you have 2 main methods which are called to send a request to the API : callPOSTAPI and callGETAPI tey each take a last argument to specify if the verbose/debug output should be printed.

If you want to enable it globally for all call you can replace at line 9 async function callPOSTAPI(url, data, verbose){ by async function callPOSTAPI(url, data, verbose = true){ and at line 45 async function callGETAPI(url, verbose){ by async function callGETAPI(url, verbose = true){

Be aware that it will spew a lot of info in the console this way, including your tokens & credentials.

If you want to target only a specific call, locate it and add a true as an extra argument. For exemple, to enable debu on this call : return (await callPOSTAPI("/api/1/vehicles/" + vehId + "/command/charge_stop")).response; change it to this : return (await callPOSTAPI("/api/1/vehicles/" + vehId + "/command/charge_stop", null, true)).response;

jaybee808 commented 4 years ago

great, thanks... i will try it right away

jaybee808 commented 4 years ago

any Ideas? [15:23:57]Companion launched by [peerAppLaunched] [HOST][15:23:58]App Started companion/index.js:30,9 [15:23:59]Got request : CheckToken companion/TeslaAPI.js:90,3 [15:23:59]Checking Token in local storage ... companion/TeslaAPI.js:101,3 [15:23:59] Token available : qts-e31a65xxxxxx_mytoken_xxxxxxxx companion/TeslaAPI.js:103,3 [15:23:59] Checking Token expiracy ... companion/TeslaAPI.js:104,3 [15:23:59] Token expire at : Tue Oct 20 2020 12:18:12 GMT+0200 (CEST) companion/TeslaAPI.js:115,3 [15:23:59] Token expiration validity OK companion/TeslaAPI.js:117,3 [15:23:59] Testing Token validity ... companion/TeslaAPI.js:48,5 [15:23:59]Calling API GET https://owner-api.teslamotors.com/api/1/vehicles companion/TeslaAPI.js:60,5 [15:24:00] - Response status : 200(OK) companion/TeslaAPI.js:64,5 [15:24:00] - Response text : {"response":[{"id":373-myID-,"vehicle_id":4034xxxxxxx,"vin":"5YJ3E7xxxxxxxxx","display_name":"mycarsname","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["1axxxxxxxxxxxx","35xxxxxxxxxx"],"state":"asleep","in_service":false,"id_s":"373xxxxxxxxxxxxxxxx","calendar_enabled":true,"api_version":10,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":null}],"count":1} companion/TeslaAPI.js:121,5 [15:24:00] Token validity error : TypeError: Body was already used. companion/TeslaAPI.js:122,5 [15:24:00] Regenerating it ... companion/TeslaAPI.js:130,3 [15:24:00] Token All good app/index.js:71,3 [15:24:01]Got data : {"data":{"type":"response","response":"InitOk"}} app/index.js:86,9 [15:24:01]Got response message : InitOk companion/index.js:30,9 [15:24:01]Got request : WakeUp companion/TeslaAPI.js:48,5 [15:24:01]Calling API GET https://owner-api.teslamotors.com/api/1/vehicles companion/TeslaAPI.js:60,5 [15:24:01] - Response status : 200(OK) companion/TeslaAPI.js:64,5 [15:24:01] - Response text : {"response":[{"id":373xxxxxxxxxxxxxxxx,"vehicle_id":40xxxxxxxxxx,"vin":"5YJ3E7xxxxxxxxxxxxxxx","display_name":"Snxxxxxxx","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["1axxxxxxxxxxxxxx","35xxxxxxxxxxxx"],"state":"asleep","in_service":false,"id_s":"373xxxxxxxxxxxxxxxx","calendar_enabled":true,"api_version":10,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":null}],"count":1} app/index.js:71,3 [15:24:01]Got data : {"data":{"type":"error","error":{}}} app/index.js:104,1 [15:24:01]Unknow type received : error

remygrandin commented 4 years ago

the first API answer seem good, so the app must raise an exception somewhere before ending the wakeup api call. Can you try adding a throw; between line 223 and 224 of the compagnion "index.js" ?

jaybee808 commented 4 years ago

just like that ? ;) what expression/argument do i want to throw?

companion/index.js:224,7 TS1109: Expression expected.

jaybee808 commented 4 years ago

by the Way. there ist no difference, if i wake up the car manually. The error remains

[HOST][18:15:26]App Started [HOST][18:15:27]Launch complete - durations: foregrounding(816ms), first paint(163ms), total(995ms). companion/index.js:30,9 [18:15:27]Got request : CheckToken companion/TeslaAPI.js:90,3 [18:15:27]Checking Token in local storage ... companion/TeslaAPI.js:101,3 [18:15:27] Token available : qts-6xxxxxxxxxxxxx companion/TeslaAPI.js:103,3 [18:15:27] Checking Token expiracy ... companion/TeslaAPI.js:104,3 [18:15:27] Token expire at : Tue Oct 20 2020 18:15:00 GMT+0200 (CEST) companion/TeslaAPI.js:115,3 [18:15:27] Token expiration validity OK companion/TeslaAPI.js:117,3 [18:15:27] Testing Token validity ... companion/TeslaAPI.js:48,5 [18:15:27]Calling API GET https://owner-api.teslamotors.com/api/1/vehicles companion/TeslaAPI.js:60,5 [18:15:28] - Response status : 200(OK) companion/TeslaAPI.js:64,5 [18:15:28] - Response text : {"response":[{"id":37xxxxxxx,"vehicle_id":4xxxxxxxxx,"vin":"5YJ3xxxxxxxxxxxx","display_name":"Sxxxxxx","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["8bxxxxxxxxxxxxxxx","67xxxxxxxxf"],"state":"online","in_service":false,"id_s":"37xxxxxx","calendar_enabled":true,"api_version":10,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":null}],"count":1} companion/TeslaAPI.js:121,5 [18:15:28] Token validity error : TypeError: Body was already used. companion/TeslaAPI.js:122,5 [18:15:28] Regenerating it ... companion/TeslaAPI.js:130,3 [18:15:29] Token All good app/index.js:71,3 [18:15:29]Got data : {"data":{"type":"response","response":"InitOk"}} app/index.js:86,9 [18:15:29]Got response message : InitOk companion/index.js:30,9 [18:15:29]Got request : WakeUp companion/TeslaAPI.js:48,5 [18:15:29]Calling API GET https://owner-api.teslamotors.com/api/1/vehicles companion/TeslaAPI.js:60,5 [18:15:29] - Response status : 200(OK) companion/TeslaAPI.js:64,5 [18:15:29] - Response text : {"response":[{"id":3xxxxxxxxxx,"vehicle_id":40xxxxxxxxxx,"vin":"5YJxxxxxxxxxxxx","display_name":"Sxxxxxxe","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["8xxxxxxxxxxxxx","6xxxxxxxxxxxxx"],"state":"online","in_service":false,"id_s":"37xxxxxxxxxxxxx","calendar_enabled":true,"api_version":10,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":null}],"count":1} app/index.js:71,3 [18:15:29]Got data : {"data":{"type":"error","error":{}}}

jaybee808 commented 4 years ago

any ideas? Thanks

remygrandin commented 4 years ago

Hi,

Sorry for the wait, I was away from my rig durring a few days.

I will whip up a branch with all try catch disabled to try to get to the bottom of this error. I will keep you updated as soon as it's up so you can try it on your side.

jaybee808 commented 4 years ago

HI, thanks, no problem. if you need anything from me go ahead ;).