From 57ac83630742affbf4e26ba40f62533b52fee4e8 Mon Sep 17 00:00:00 2001 From: Florian BEZANNIER <48728684+flobz@users.noreply.github.com> Date: Sat, 6 Nov 2021 20:20:56 +0100 Subject: [PATCH 1/4] Update FAQ.md --- FAQ.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/FAQ.md b/FAQ.md index 7180c03..59579f9 100644 --- a/FAQ.md +++ b/FAQ.md @@ -23,8 +23,15 @@ Your psa account is locked because you makes 20 sms activation. To unlock do thi 4. Connect and test remote control, it should say that you need to reset your account 6. If the remote control work on your smartphone it will work with psa_car_controller -### 3. No data to show -The app record your position if "-r" argument is provided. +### 3. No data in dashboard +The app record your position and other information if "-r" argument is provided and if data are fetched. + +Data are fetched in the following scenarios: +- charge control is enabled with "-c" program argument +- refresh is enabled with "-R" +- You use "get_vehicleinfo" API endpoint + + You need to make few trips to be able to see stats in the dashboard. ### 4. Permission error From 6b70505587fb31f7bcbed94a8cb7a8f0a64f3c9d Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 6 Nov 2021 13:04:16 +0100 Subject: [PATCH 2/4] fix ssl error in container --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index a158a02..f3c564e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy androguard python3-flask' +ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy androguard python3-flask python3-paho-mqtt ca-certificates' +ARG DEBIAN_FRONTEND=noninteractive FROM debian:bullseye-slim AS builder ARG PYTHON_DEP RUN BUILD_DEP='python3-pip python3-setuptools python3-dev libblas-dev liblapack-dev gfortran libatlas3-base' ; \ apt-get update && apt-get install -y --no-install-recommends $BUILD_DEP $PYTHON_DEP; COPY . /psa_car_controller/ -RUN pip3 install --system --no-cache-dir -r /psa_car_controller/requirements.txt +RUN pip3 install --system --no-cache-dir -r /psa_car_controller/requirements.txt EXPOSE 5000 FROM debian:bullseye-slim @@ -15,6 +16,8 @@ ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CON COPY --from=builder /var/lib/apt /var/lib/apt COPY --from=builder /var/cache/apt/ /var/cache/apt/ COPY --from=builder /usr/local/lib /usr/local/lib -RUN apt-get install -y --no-install-recommends $PYTHON_DEP && apt-get clean ; rm -rf /var/lib/apt/lists/* +RUN apt-get install -y --no-install-recommends $PYTHON_DEP && \ + apt-get clean ; \ + rm -rf /var/lib/apt/lists/* COPY . /psa_car_controller/ CMD /psa_car_controller/docker_files/init.sh \ No newline at end of file From 9e67deaf994122d240ae8a554b3b28f1b7ac005d Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 25 Nov 2021 17:54:27 +0100 Subject: [PATCH 3/4] fix #281 --- app_decoder.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app_decoder.py b/app_decoder.py index fe5e24a..3ba458a 100755 --- a/app_decoder.py +++ b/app_decoder.py @@ -26,7 +26,7 @@ DOWNLOAD_URL = "https://github.com/flobz/psa_apk/raw/main/" def save_key_to_pem(pfx_data, pfx_password): private_key, certificate = pkcs12.load_key_and_certificates(pfx_data, - bytes.fromhex(pfx_password), default_backend())[:2] + pfx_password, default_backend())[:2] try: os.mkdir("certs") except FileExistsError: @@ -63,7 +63,7 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, ## Get Customer id site_code = BRAND[package_name]["brand_code"] + "_" + country_code + "_ESP" pfx_cert = a.get_file("assets/MWPMYMA1.pfx") - save_key_to_pem(pfx_cert, "") + save_key_to_pem(pfx_cert, b"y5Y2my5B") try: res = requests.post(HOST_BRANDID_PROD + "/GetAccessToken", headers={ @@ -80,18 +80,19 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, ) token = res.json()["accessToken"] - except: # pylint: disable=bare-except + except Exception as ex: msg = traceback.format_exc() + f"\nHOST_BRANDID : {HOST_BRANDID_PROD} sitecode: {site_code}" try: msg += res.text - except: + except: # pylint: disable=bare-except pass logger.error(msg) - raise Exception(msg) + raise Exception(msg) from ex try: + version = "1.33.0" res2 = requests.post( f"https://mw-{BRAND[package_name]['brand_code'].lower()}-m2c.mym.awsmpsa.com/api/v1/" - f"user?culture=fr_FR&width=1080&v=1.27.0", + f"user?culture=fr_FR&width=1080&v=" + version, data=json.dumps({"site_code": site_code, "ticket": token}), headers={ "Connection": "Keep-Alive", @@ -99,21 +100,21 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, "Source-Agent": "App-Android", "Token": token, "User-Agent": "okhttp/4.8.0", - "Version": "1.27.0" + "Version": version }, cert=("certs/public.pem", "certs/private.pem"), ) res_dict = res2.json()["success"] customer_id = BRAND[package_name]["brand_code"] + "-" + res_dict["id"] - except: # pylint: disable=bare-except + except Exception as ex: msg = traceback.format_exc() try: msg += res2.text - except: + except: # pylint: disable=bare-except pass logger.error(msg) - Exception(msg) + raise Exception(msg) from ex # Psacc psacc = MyPSACC(None, client_id, client_secret, REMOTE_REFRESH_TOKEN, customer_id, BRAND[package_name]["realm"], country_code) From 1074db6d6a40192df92be7bec21ab57a4c72238a Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 27 Nov 2021 08:08:16 +0100 Subject: [PATCH 4/4] fix app_decoder for other languages than fr --- app_decoder.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app_decoder.py b/app_decoder.py index 3ba458a..65e8d83 100755 --- a/app_decoder.py +++ b/app_decoder.py @@ -20,8 +20,8 @@ BRAND = {"com.psa.mym.myopel": {"realm": "clientsB2COpel", "brand_code": "OP", " "com.psa.mym.myds": {"realm": "clientsB2CDS", "brand_code": "DS", "app_name": "MyDS"}, "com.psa.mym.myvauxhall": {"realm": "clientsB2CVauxhall", "brand_code": "VX", "app_name": "MyVauxhall"} } - DOWNLOAD_URL = "https://github.com/flobz/psa_apk/raw/main/" +APP_VERSION = "1.33.0" def save_key_to_pem(pfx_data, pfx_password): @@ -48,6 +48,11 @@ def urlretrieve(url, path): f.write(chunk) +def get_cultures_code(file, country_code): + cultures = json.loads(file) + return cultures[country_code]["languages"][0] + + def firstLaunchConfig(package_name, client_email, client_password, country_code, # pylint: disable=too-many-locals config_prefix=""): filename = package_name.split(".")[-1] + ".apk" @@ -60,6 +65,7 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, client_secret = resources.get_string(package_name, "PSA_API_CLIENT_SECRET_PROD")[1] HOST_BRANDID_PROD = resources.get_string(package_name, "HOST_BRANDID_PROD")[1] REMOTE_REFRESH_TOKEN = None + culture = get_cultures_code(a.get_file("res/raw/cultures.json"), country_code) ## Get Customer id site_code = BRAND[package_name]["brand_code"] + "_" + country_code + "_ESP" pfx_cert = a.get_file("assets/MWPMYMA1.pfx") @@ -84,15 +90,18 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, msg = traceback.format_exc() + f"\nHOST_BRANDID : {HOST_BRANDID_PROD} sitecode: {site_code}" try: msg += res.text - except: # pylint: disable=bare-except + except: # pylint: disable=bare-except pass logger.error(msg) raise Exception(msg) from ex try: - version = "1.33.0" res2 = requests.post( - f"https://mw-{BRAND[package_name]['brand_code'].lower()}-m2c.mym.awsmpsa.com/api/v1/" - f"user?culture=fr_FR&width=1080&v=" + version, + f"https://mw-{BRAND[package_name]['brand_code'].lower()}-m2c.mym.awsmpsa.com/api/v1/user", + params={ + "culture": culture, + "width": 1080, + "version": APP_VERSION + }, data=json.dumps({"site_code": site_code, "ticket": token}), headers={ "Connection": "Keep-Alive", @@ -100,7 +109,7 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, "Source-Agent": "App-Android", "Token": token, "User-Agent": "okhttp/4.8.0", - "Version": version + "Version": APP_VERSION }, cert=("certs/public.pem", "certs/private.pem"), )