mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 17:06:18 +00:00
update docs
This commit is contained in:
@@ -17,64 +17,19 @@ With this app you will be able to :
|
||||
- visualize altitude trip curve
|
||||
- get car charging co2 emission
|
||||
- get car charging price
|
||||
- send live data to ABetterRoutePlanner
|
||||
|
||||
The official api is documented [here](https://developer.groupe-psa.io/webapi/b2c/quickstart/connect/#article) but it is not totally up to date, and contains some errors.
|
||||
|
||||
A video in French was made by vlycop to explain how to use this application : https://youtu.be/XO7-N7G3biU
|
||||
|
||||
For information on configuring the psa_car_controller Docker container [see this section](#docker).
|
||||
|
||||
## I. Get credentials
|
||||
We need to get credentials from the android app.
|
||||
We will retrieve this information:
|
||||
- client-id and client-secret for the api
|
||||
- some url to login
|
||||
|
||||
1.1 Download the app on your computer, the original MyPeugeot app can be downloaded [here](https://apkpure.com/fr/mypeugeot-app/com.psa.mym.mypeugeot/download/2107-APK?from=versions%2Fversion) for example (please download version **1.27**).
|
||||
|
||||
1.2 Install requirements :
|
||||
|
||||
- You need **python >= 3.6**
|
||||
|
||||
- On debian based distribution you can install some requirement from repos:
|
||||
|
||||
```sudo apt-get install python3-typing-extensions python3-pandas python3-plotly python3-paho-mqtt python3-six python3-dateutil python3-brotli libblas-dev liblapack-dev gfortran python3-pycryptodome python3-numpy libatlas3-base python3-cryptography```
|
||||
|
||||
- For everyone :
|
||||
```pip3 install -r requirements.txt```
|
||||
|
||||
1.3 run the decoder script : ```python3 app_decoder.py <path to my apk file>```
|
||||
|
||||
mypeugeot email: <write your mypeugeot email>
|
||||
mypeugeot password: <write your mypeugeot password>
|
||||
What is the car api realm : clientsB2CPeugeot, clientsB2CDS, clientsB2COpel, clientsB2CVauxhall
|
||||
clientsB2CPeugeot
|
||||
What is your country code ? (ex: FR, GB, DE, ES...)
|
||||
FR
|
||||
save config change
|
||||
|
||||
Your vehicles: {'VINNUBMER': {'id': 'vehicule id'}}
|
||||
|
||||
1.4 If it works you will have VIN of your vehicles and there ids in the last line. The script generates a test.json file with all credentials needed.
|
||||
For information on configuring the psa_car_controller Docker container [see this page]
|
||||
|
||||
## I. Installation
|
||||
- [Installation on Linux or Windows](docs/Install.md)
|
||||
- [Installation in Docker](docs/Docker.md)
|
||||
## II. Use the app
|
||||
|
||||
|
||||
1. start the app:
|
||||
|
||||
Start the app with charge control enabled :
|
||||
|
||||
``python3 server.py -f test.json -c charge_config1.json``
|
||||
|
||||
At the first launch you will receive an SMS, and you will be asked to give it and also give your pin code (the four-digit code that your use on the android app).
|
||||
If it failed you can remove the file otp.bin and retry.
|
||||
|
||||
You can see all options available with :
|
||||
``python3 server.py -h``
|
||||
|
||||
|
||||
2. Test it
|
||||
|
||||
2.1 Get the car state :
|
||||
http://localhost:5000/get_vehicleinfo/YOURVIN
|
||||
|
||||
@@ -97,7 +52,7 @@ We will retrieve this information:
|
||||
http://localhost:5000/preconditioning/YOURVIN/1 or 0
|
||||
|
||||
|
||||
## III. Use the dashboard
|
||||
## III. Use the dashboard
|
||||
|
||||
You can add the -r argument to record the position of the vehicle and retrieve this information in a dashboard.
|
||||
|
||||
@@ -109,7 +64,7 @@ You will be able to visualize your trips, your consumption and some statistics:
|
||||

|
||||
- You have to add an api key from https://home.openweathermap.org/ in your config file, to be able to see your consumption vs exterior temperature.
|
||||
- You have to add an api key from https://co2signal.com/ to have your C02 emission by KM (in France the key isn't needed).
|
||||
### Charge price calculation
|
||||
### IV. Charge price calculation
|
||||
The dashboard can give you the price by kilometer and price by kw that you pay.
|
||||
You just have to set the price in the config file.
|
||||
|
||||
@@ -120,85 +75,19 @@ If you have a special price during the night you can set "night price", "night h
|
||||
Hours need to be in the following format "23h12"?
|
||||
|
||||
You can modify a price manually in the dashboard. It can be useful if you use public charge point.
|
||||
## IV. Connect your home automation system:
|
||||
## V. Connect your home automation system:
|
||||
- [Domoticz](docs/domoticz/Domoticz.md)
|
||||
- [HomeAssistant](https://github.com/Flodu31/HomeAssistant-PeugeotIntegration)
|
||||
- Jeedom (Anyone can share the procedure ?)
|
||||
|
||||
## FAQ
|
||||
If you have a problem, or a question please check if the answer isn't in the [FAQ](FAQ.md).
|
||||
If you need information to contribute or edit this program go [here](docs/Develop.md).
|
||||
## Connect to A better Route Planner
|
||||
You can connect the app to ABRP, see [this page](docs/abrp.md)
|
||||
## API documentation
|
||||
The api documentation is described here : [api_spec.md](api_spec.md).
|
||||
You can use all functions from the doc, for example :
|
||||
```myp.api().get_car_last_position(myp.get_vehicle_id_with_vin("myvin"))```
|
||||
## More information
|
||||
To analyse the traffics between the app and psa server, you can use mitmproxy.
|
||||
You will need the client certificate present in the apk at asssets/MWPMYMA1.pfx
|
||||
```bash
|
||||
# decrypt the pfx file (there is no password)
|
||||
openssl pkcs12 -in MWPMYMA1.pfx -out MWPMYMA1.pem -nodes
|
||||
```
|
||||
Then you can use mitmproxy for example:
|
||||
|
||||
```
|
||||
mitmproxy --set client_certs=MWPMYMA1.pem
|
||||
```
|
||||
|
||||
## Donation
|
||||
If you want to thank me for my work :smile:
|
||||
|
||||
[](https://www.paypal.com/donate?hosted_button_id=SM652WPXFNCXS)
|
||||
|
||||
---
|
||||
# Docker
|
||||
|
||||
A containerised version of the psa_car_controller Python scripts by Flobz.
|
||||
- Docker Hub: https://hub.docker.com/r/sockhamster/psa_car_controller
|
||||
|
||||
### Overview
|
||||
Once the container is running, the configuration of the psa_car_controller app is near-identical to setup instructions detailed in the app's readme.
|
||||
|
||||
You'll still need to make sure you have an apk for the appropriate Android app that it's attempting to use. The examples in this readme use the MyVauxhall app v1.27.1 from APKPure:
|
||||
https://m.apkpure.com/myvauxhall-the-official-app-for-vauxhall-drivers/com.psa.mym.myvauxhall/download/2107-APK?from=versions%2Fversion
|
||||
|
||||
On your Docker host, create a config folder which will be mapped to the container and used to store all persistent data. Copy your APK into this folder.
|
||||
|
||||
### Installation
|
||||
Create the container, detached, exposing port 8180, and mapping the a new config folder on your host to /config inside the container:
|
||||
|
||||
```
|
||||
docker run -d -ti --name psa_car_controller1 \
|
||||
--publish 8180:8180 \
|
||||
-v /host_path/config:/config \
|
||||
--restart unless-stopped \
|
||||
psa_car_controller
|
||||
```
|
||||
|
||||
Connect to the bash shell of the newly created container:
|
||||
```
|
||||
docker exec -it psa_car_controller1 /bin/bash
|
||||
```
|
||||
|
||||
Inside the container, run the app_decoder.py script. You'll be prompted for the credentials you use to log into the app on your mobile device usually, plus your country code. If the script gives you a Success! message then move on:
|
||||
```
|
||||
python3 /psa_car_controller/app_decoder.py /config/com.psa.mym.myvauxhall_1.27.1.apk
|
||||
```
|
||||
Start server.py for a first run:
|
||||
```
|
||||
python3 /psa_car_controller/server.py -f /config/test.json -c /config/charge_config1.json -p 8180 -l 0.0.0.0 -r -b /config
|
||||
```
|
||||
You will be prompted to enter a code, sent you you by SMS to your registered mobile number, and the PIN for your account. Sometimes it asks twice (???), but once accepted the service should run. Allow it to run for about a minute before pressing ctrl+c to quit. You should end up back at the bash prompt within the container.
|
||||
|
||||
The final task is to update the container's configuration file to tell it to run the service automatically on next boot. This is done by editing /config/dockerconfig.conf and changing the SHELL_ONLY parameter to FALSE. Alternatively, paste the below command into your shell one by one. These will update the dockerconfig.conf file, exit the container's bash shell, stop the container, then restart the container.
|
||||
|
||||
```
|
||||
echo "export SHELL_ONLY=\"FALSE\"" > /config/dockerconfig.conf
|
||||
exit
|
||||
docker stop psa_car_controller1
|
||||
docker start psa_car_controller1
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# Developer Information
|
||||
## Contributing
|
||||
|
||||
Before create a pull request check your code with Prospector.
|
||||
You can install it with
|
||||
|
||||
```
|
||||
pip3 install -r requirements-dev.txt```
|
||||
#Then on the root of the git project:
|
||||
prospector
|
||||
```
|
||||
## API documentation
|
||||
The api documentation is described here : [api_spec.md](api_spec.md).
|
||||
You can use all functions from the doc, for example :
|
||||
```myp.api().get_car_last_position(myp.get_vehicle_id_with_vin("myvin"))```
|
||||
## Analysing request
|
||||
To analyse the traffics between the app and psa server, you can use mitmproxy.
|
||||
You will need the client certificate present in the apk at asssets/MWPMYMA1.pfx
|
||||
```bash
|
||||
# decrypt the pfx file (there is no password)
|
||||
openssl pkcs12 -in MWPMYMA1.pfx -out MWPMYMA1.pem -nodes
|
||||
```
|
||||
Then you can use mitmproxy for example:
|
||||
|
||||
```
|
||||
mitmproxy --set client_certs=MWPMYMA1.pem
|
||||
```
|
||||
|
||||
For being able to see trafic from android app you need a rooted phone, you can use an android emulator then follow this:
|
||||
https://docs.mitmproxy.org/stable/howto-install-system-trusted-ca-android/
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Docker installation
|
||||
|
||||
A containerised version of the psa_car_controller Python scripts by Flobz.
|
||||
- Docker Hub: https://hub.docker.com/r/sockhamster/psa_car_controller
|
||||
|
||||
### Overview
|
||||
Once the container is running, the configuration of the psa_car_controller app is near-identical to setup instructions detailed in the app's readme.
|
||||
|
||||
You'll still need to make sure you have an apk for the appropriate Android app that it's attempting to use. The examples in this readme use the MyVauxhall app v1.27.1 from APKPure:
|
||||
https://m.apkpure.com/myvauxhall-the-official-app-for-vauxhall-drivers/com.psa.mym.myvauxhall/download/2107-APK?from=versions%2Fversion
|
||||
|
||||
On your Docker host, create a config folder which will be mapped to the container and used to store all persistent data. Copy your APK into this folder.
|
||||
|
||||
### Installation
|
||||
Create the container, detached, exposing port 5000, and mapping the a new config folder on your host to /config inside the container:
|
||||
|
||||
```
|
||||
docker run -d -ti --name psa_car_controller1 \
|
||||
--publish 5000:5000 \
|
||||
-v /host_path/config:/config \
|
||||
--restart unless-stopped \
|
||||
psa_car_controller
|
||||
```
|
||||
|
||||
Connect to the bash shell of the newly created container:
|
||||
```
|
||||
docker exec -it psa_car_controller1 /bin/bash
|
||||
```
|
||||
|
||||
Inside the container, run the app_decoder.py script. You'll be prompted for the credentials you use to log into the app on your mobile device usually, plus your country code. If the script gives you a Success! message then move on:
|
||||
```
|
||||
python3 /psa_car_controller/app_decoder.py /config/com.psa.mym.myvauxhall_1.27.1.apk
|
||||
```
|
||||
Start server.py for a first run:
|
||||
```
|
||||
python3 /psa_car_controller/server.py -f /config/test.json -c /config/charge_config1.json -p 5000 -l 0.0.0.0 -r -b /config
|
||||
```
|
||||
You will be prompted to enter a code, sent you you by SMS to your registered mobile number, and the PIN for your account. Sometimes it asks twice (???), but once accepted the service should run. Allow it to run for about a minute before pressing ctrl+c to quit. You should end up back at the bash prompt within the container.
|
||||
|
||||
The final task is to update the container's configuration file to tell it to run the service automatically on next boot. This is done by editing /config/dockerconfig.conf and changing the SHELL_ONLY parameter to FALSE. Alternatively, paste the below command into your shell one by one. These will update the dockerconfig.conf file, exit the container's bash shell, stop the container, then restart the container.
|
||||
|
||||
```
|
||||
echo "export SHELL_ONLY=\"FALSE\"" > /config/dockerconfig.conf
|
||||
exit
|
||||
docker stop psa_car_controller1
|
||||
docker start psa_car_controller1
|
||||
```
|
||||
@@ -0,0 +1,49 @@
|
||||
# Installation
|
||||
We need to get credentials from the android app.
|
||||
We will retrieve this information:
|
||||
- client-id and client-secret for the api
|
||||
- some url to login
|
||||
|
||||
1.1 Download the app on your computer, the original MyPeugeot app can be downloaded [here](https://apkpure.com/fr/mypeugeot-app/com.psa.mym.mypeugeot/download/2107-APK?from=versions%2Fversion) for example (please download version **1.27**).
|
||||
|
||||
1.2 Install requirements :
|
||||
|
||||
- You need **python >= 3.6**
|
||||
|
||||
- On debian based distribution you can install some requirement from repos, it's faster than installtion with pip:
|
||||
|
||||
```
|
||||
sudo apt-get install python3-typing-extensions python3-pandas python3-plotly python3-paho-mqtt python3-six python3-dateutil python3-brotli libblas-dev liblapack-dev gfortran python3-pycryptodome python3-numpy libatlas3-base python3-cryptography
|
||||
```
|
||||
|
||||
- For everyone :
|
||||
```pip3 install -r requirements.txt```
|
||||
|
||||
1.3 run the decoder script : ```python3 app_decoder.py <path to my apk file>```
|
||||
|
||||
mypeugeot email: <write your mypeugeot email>
|
||||
mypeugeot password: <write your mypeugeot password>
|
||||
What is the car api realm : clientsB2CPeugeot, clientsB2CDS, clientsB2COpel, clientsB2CVauxhall
|
||||
clientsB2CPeugeot
|
||||
What is your country code ? (ex: FR, GB, DE, ES...)
|
||||
FR
|
||||
save config change
|
||||
|
||||
Your vehicles: {'VINNUBMER': {'id': 'vehicule id'}}
|
||||
|
||||
1.4 If it works you will have VIN of your vehicles and there ids in the last line.
|
||||
The script generates a test.json file with all credentials needed.
|
||||
|
||||
|
||||
|
||||
1.5 start the app:
|
||||
|
||||
Start the app with charge control enabled :
|
||||
|
||||
``python3 server.py -f test.json -c charge_config1.json``
|
||||
|
||||
At the first launch you will receive an SMS, and you will be asked to give it and also give your pin code (the four-digit code that your use on the android app).
|
||||
If it failed you can remove the file otp.bin and retry.
|
||||
|
||||
You can see all options available with :
|
||||
``python3 server.py -h``
|
||||
Reference in New Issue
Block a user