flobz / psa_car_controller

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

MyVauxhall "NEED_ACTIVATION" error #99

Closed sOckhamSter closed 3 years ago

sOckhamSter commented 3 years ago

Describe the bug When executing the app_decoder.py script with a MyVauxhall APK (tested with 1.27.0, 1.27.1, 1.29.2), after inputting 'GB' as the country code, a return code of NEED_ACTIVATION is thrown instead of success.

Requested API level 29 is larger than maximum we have, returning API level 28 instead.                                                                                              
APK loaded !                                                                                                        
MyVauxhall email: xxxxx@xxxxx.xxx                                                                          
MyVauxhall password:                                                                                                
What is your country code ? (ex: FR, GB, DE, ES...)                                                                 
GB                                                                                                                  
Traceback (most recent call last):                                                                                  
  File "/psa_car_controller/psa_car_controller/app_decoder.py", line 112, in <module>                               
    token = res.json()["accessToken"]                                                                               
KeyError: 'accessToken'                                                                                             
HOST_BRANDID : https://id-dcr.vauxhall.co.uk/mobile-services sitecode: 0V_GB_ESP                                    
{"returnCode":"NEED_ACTIVATION"}

To Reproduce Steps to reproduce the behavior:

  1. python3 app_decoder.py MyVauxhall.apk

Attempting to use this in the UK to connect to a Vauxhall Corsa-e. Any ideas at all what may be causing the error? On a separate bug thread that someone else had the same error code at one point: https://github.com/flobz/psa_car_controller/issues/20#issuecomment-770433684

flobz commented 3 years ago

You are the first Vauxhall user apparently ! It should be fixed with 97b6ec987dfc81c05701440b78b0c36971030f72.

sOckhamSter commented 3 years ago

Perfect, thank you, I now have a success message! I'm going to attempt to containerise the script so I'll let you know once I've managed it. Getting it working is the first step of course. What would be really great to help with that, if I could make a suggestion, is the ability to specify in a config file somewhere the location of the generated files from app_decoder. That way a folder can be mounted to the container for a user to drop their test.json / charge_config1.json and any other dynamically created files that need to be persistent. At the moment, I'll need to do a file-by-file mapping for that instead which isn't going to be as easy for end users. But anyway, thank you again!

Flodu31 commented 3 years ago

Interested too, to be able to run it on docker/kubernetes

sOckhamSter commented 3 years ago

I have it running in a Python container on Docker right now, but manually executed. I can tidy all of that up and build the container with all the required pre-reqs, auto-executing the server.py on start. But, the first run of asking for the SMS / PIN is going to take some lateral thinking!

flobz commented 3 years ago
  1. Do a :
    python3 server.py -h
  2. Look at the server.py file also, some parameter can be set with environment variable
  3. You can start the app from an another dir that will be mounted on the host system. Like this, log and config files will be accessible directly to the host. I look forward to see it in a container ! Thanks.
flobz commented 3 years ago

But, the first run of asking for the SMS / PIN is going to take some lateral thinking!

SMS is asked only at the first start so user can do: 1.docker run -ti --rm -v ./configdir:/configdir psacc_image

  1. Enter the sms code
  2. the user do ctrl-c
  3. rerun in background the container with configdir mounted
fn87 commented 3 years ago

Would be wonderful to be able to run this as an addon (container) in Home assistant. Should be possible to do a config flow there for PIN and code input.

sOckhamSter commented 3 years ago

But, the first run of asking for the SMS / PIN is going to take some lateral thinking!

SMS is asked only at the first start so user can do: 1.docker run -ti --rm -v ./configdir:/configdir psacc_image

  1. Enter the sms code
  2. the user do ctrl-c
  3. rerun in background the container with configdir mounted

So what are you considering as the configdir location? In my image I'm creating a blank directory in the root called /config. It'll be totally empty inside the image and is designed for just the test.json and charge_config1.json files to be dropped in. When server.py asked for the SMS/PIN, does it cache something somewhere? I think I need to be able to specify the location of that cached data into the /config directory so as it can become persistent instead of being lost if the container is recreated.

Note: It's the -rm part of your docker run command that made me think about this. If I use the docker run command with -rm then the container disappears once I ctrl-c, and when I try to spin up another container using the same /config location then I need to go through the whole process again. But, if I initially create the container without -rm (and put in all of the other parameters I need), then I can make the SMS/PIN persist.

sOckhamSter commented 3 years ago

I've moved the chat to Discussions so as to avoid clogging up this now-fixed bug thread: https://github.com/flobz/psa_car_controller/discussions/102