From 9ea8c8a08d14c13aeb0b5f3c93fc0090feb4179f Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Wed, 23 Jun 2021 19:23:14 +0200 Subject: [PATCH 01/15] fix init --- docker_files/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_files/init.sh b/docker_files/init.sh index 0abb4cb..abc486c 100644 --- a/docker_files/init.sh +++ b/docker_files/init.sh @@ -1,4 +1,4 @@ #!/bin/bash echo "Containerised psa_car_controller loading..." cd "$PSACC_CONFIG_DIR" -python3 /psa_car_controller/server.py -p "$PSACC_PORT" -l 0.0.0.0 -b "$PSACC_BASE_PATH" "$PSACC_OPTIONS" +python3 /psa_car_controller/server.py -p $PSACC_PORT -l 0.0.0.0 -b $PSACC_BASE_PATH $PSACC_OPTIONS From 970b8701bae2a38ee33b4069ecc9df6daff0866b Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 24 Jun 2021 11:06:33 +0200 Subject: [PATCH 02/15] add gcc for arm64 --- Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7020051..12b7e98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,13 @@ FROM python:3-slim ARG TARGETPLATFORM COPY . /psa_car_controller/ WORKDIR /config -RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then apt-get update && apt-get install -y gcc && apt-get clean ; \ - rm -rf /var/lib/apt/lists/* ; fi ; \ - pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt ; \ - apt-get remove -y gcc 2> /dev/null ; \ - apt-get autoremove -y +RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + apt-get update && apt-get install -y gcc && apt-get clean ; \ + rm -rf /var/lib/apt/lists/* ; \ + fi ; \ + pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt ; \ + apt-get remove -y gcc 2> /dev/null ; \ + apt-get autoremove -y EXPOSE 5000 RUN chmod +x /psa_car_controller/docker_files/init.sh ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CONFIG_DIR="/config" From d6806772a50912aeaf63b406e3a4485d93461a4e Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 24 Jun 2021 14:30:26 +0200 Subject: [PATCH 03/15] fix args quotes --- docker_files/init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker_files/init.sh b/docker_files/init.sh index abc486c..db326bc 100644 --- a/docker_files/init.sh +++ b/docker_files/init.sh @@ -1,4 +1,5 @@ #!/bin/bash echo "Containerised psa_car_controller loading..." cd "$PSACC_CONFIG_DIR" -python3 /psa_car_controller/server.py -p $PSACC_PORT -l 0.0.0.0 -b $PSACC_BASE_PATH $PSACC_OPTIONS +ARGS="-p $PSACC_PORT -l 0.0.0.0 -b $PSACC_BASE_PATH $PSACC_OPTIONS" +python3 /psa_car_controller/server.py $ARGS From 25ddf0abbb961009470a06e5aa365978df90bac5 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 24 Jun 2021 14:34:29 +0200 Subject: [PATCH 04/15] add g++ dep --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12b7e98..a99cf8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,13 @@ FROM python:3-slim ARG TARGETPLATFORM COPY . /psa_car_controller/ WORKDIR /config -RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - apt-get update && apt-get install -y gcc && apt-get clean ; \ +RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then + apt-get update && apt-get install -y gcc g++ && apt-get clean ; \ rm -rf /var/lib/apt/lists/* ; \ - fi ; \ - pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt ; \ - apt-get remove -y gcc 2> /dev/null ; \ - apt-get autoremove -y + fi ; \ + pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt && \ + apt-get remove -y gcc g++ 2> /dev/null ; \ + apt-get autoremove -y EXPOSE 5000 RUN chmod +x /psa_car_controller/docker_files/init.sh ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CONFIG_DIR="/config" From df7a266d6f0313a66bbbf4bb646dc486e264653c Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Thu, 24 Jun 2021 14:37:15 +0200 Subject: [PATCH 05/15] missing slash --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a99cf8e..8463576 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3-slim ARG TARGETPLATFORM COPY . /psa_car_controller/ WORKDIR /config -RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then +RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ apt-get update && apt-get install -y gcc g++ && apt-get clean ; \ rm -rf /var/lib/apt/lists/* ; \ fi ; \ From 6539eb7a69e9813d92218e5551f790a51115eb12 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 26 Jun 2021 07:16:59 +0200 Subject: [PATCH 06/15] fix mispelled vauxhall --- web/config_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/config_views.py b/web/config_views.py index b454240..be788c1 100644 --- a/web/config_views.py +++ b/web/config_views.py @@ -25,7 +25,7 @@ config_layout = dbc.Row(dbc.Col(className="col-md-12 col-lg-2 ml-2", children=[ {"label": "Opel", "value": "com.psa.mym.myopel"}, {"label": "Cirtroën", "value": "com.psa.mym.citroen"}, {"label": "DS", "value": "com.psa.mym.myds"}, - {"label": "Vauxhall", "value": "com.psa.mym.myvauxhll"} + {"label": "Vauxhall", "value": "com.psa.mym.myvauxhall"} ], )]), dbc.FormGroup( From 558b1b3ecaea71d1a9d6cb6beda94d3479a2eca6 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 26 Jun 2021 07:22:12 +0200 Subject: [PATCH 07/15] add execute permission --- docker_files/init.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 docker_files/init.sh diff --git a/docker_files/init.sh b/docker_files/init.sh old mode 100644 new mode 100755 From 36286ed03aedd0d7988aa73e17c058cb7607e6a3 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 26 Jun 2021 07:39:47 +0200 Subject: [PATCH 08/15] install dep from debian repo --- Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8463576..ee79571 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,11 @@ FROM python:3-slim ARG TARGETPLATFORM COPY . /psa_car_controller/ WORKDIR /config -RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - apt-get update && apt-get install -y gcc g++ && apt-get clean ; \ - rm -rf /var/lib/apt/lists/* ; \ - fi ; \ - pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt && \ - apt-get remove -y gcc g++ 2> /dev/null ; \ - apt-get autoremove -y +RUN apt-get update && apt-get install -y python3-typing-extensions python3-pandas python3-plotly python3-paho-mqtt \ + python3-six python3-dateutil python3-brotli libblas-dev liblapack-dev gfortran python3-pycryptodome \ + libatlas3-base python3-cryptography && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt EXPOSE 5000 -RUN chmod +x /psa_car_controller/docker_files/init.sh ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CONFIG_DIR="/config" CMD /psa_car_controller/docker_files/init.sh From 8bd956e8455248c0b4cfbcf20e214e42353bacd7 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sat, 26 Jun 2021 14:58:06 +0200 Subject: [PATCH 09/15] fix dep --- Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee79571..64cfc5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,15 @@ FROM python:3-slim ARG TARGETPLATFORM COPY . /psa_car_controller/ WORKDIR /config -RUN apt-get update && apt-get install -y python3-typing-extensions python3-pandas python3-plotly python3-paho-mqtt \ - python3-six python3-dateutil python3-brotli libblas-dev liblapack-dev gfortran python3-pycryptodome \ - libatlas3-base python3-cryptography && \ - apt-get clean && rm -rf /var/lib/apt/lists/* -RUN pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt +RUN ARM_DEP='build-essential libssl-dev libffi-dev gcc g++ libblas-dev liblapack-dev gfortran rustc' ; \ + if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + apt-get update && apt-get install -y $ARM_DEP && apt-get clean ; \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && \ + rm -rf /var/lib/apt/lists/* ; \ + fi ; \ + pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt && \ + apt-get remove -y $ARM_DEP 2> /dev/null ; \ + apt-get autoremove -y EXPOSE 5000 ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CONFIG_DIR="/config" CMD /psa_car_controller/docker_files/init.sh From 30b61644d333eb4026a6cef9287188d3b2884ad1 Mon Sep 17 00:00:00 2001 From: Florian BEZANNIER <48728684+flobz@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:18:25 +0200 Subject: [PATCH 10/15] add Grandland model --- libs/car_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/car_model.py b/libs/car_model.py index 12e4e4e..add4d1b 100644 --- a/libs/car_model.py +++ b/libs/car_model.py @@ -68,5 +68,7 @@ carmodels = [ CarModel("C5 Aircross", 10.8, 43), CarModel("DS7 Crossback E-Tense", 11.5, 43, reg="VR1J45GBUK.*"), CarModel("DS7 Crossback E-Tense 300 4x4", 11.5, 43, reg=" VR1J45GBUL.*"), - CarModel("508 SW Hybrid", 11.5, 45, reg=r"VR3F4DGZ.*") # VR3F4DGZTL + CarModel("508 SW Hybrid", 11.5, 45, reg=r"VR3F4DGZ.*"), # VR3F4DGZTL + CarModel("Grandland X Hybrid", 13.2, 43, reg=r"W0VZ4DGZ.*"), #W0VZ4DGZ2L + CarModel("Grandland X Hybrid 4x4", 13.2, 43, reg=r"W0VZ45GB.*") #W0VZ45GB3L ] From c2597770f5b08fc06924201fb1b60259d5ae8394 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Mon, 28 Jun 2021 14:06:19 +0200 Subject: [PATCH 11/15] fix example --- web/config_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/config_views.py b/web/config_views.py index be788c1..f38d943 100644 --- a/web/config_views.py +++ b/web/config_views.py @@ -61,7 +61,7 @@ config_layout = dbc.Row(dbc.Col(className="col-md-12 col-lg-2 ml-2", children=[ placeholder="Enter your country code", ), dbc.FormText( - "Example: FR for FRANCE or EN for England", + "Example: FR for FRANCE or GB for Great Britain...", color="secondary", ) ] From b875f62ca994c3a5b1b8e233343155cf0f848554 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Mon, 28 Jun 2021 16:13:20 +0200 Subject: [PATCH 12/15] add grafana --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98eab55..f8f4a20 100644 --- a/README.md +++ b/README.md @@ -85,16 +85,16 @@ 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. -## V. Connect your home automation system: +## V. Connection to other services: - [Domoticz](docs/domoticz/Domoticz.md) - [HomeAssistant](https://github.com/Flodu31/HomeAssistant-PeugeotIntegration) - Jeedom (Anyone can share the procedure ?) +- You can send live car status to ABRP (A better Route Planner), see [this page](docs/abrp.md) +- [Grafana](https://github.com/flobz/psa_car_controller/issues/161) ## 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) ## Donation If you want to thank me for my work :smile: From 504fbc90caa216c5ef27648dde162bf14f7671ff Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Wed, 30 Jun 2021 00:16:53 +0200 Subject: [PATCH 13/15] change docker src img --- Dockerfile | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64cfc5f..54e1202 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,20 @@ -FROM python:3-slim -ARG TARGETPLATFORM +ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-plotly python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy' + +FROM debian:buster-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/ -WORKDIR /config -RUN ARM_DEP='build-essential libssl-dev libffi-dev gcc g++ libblas-dev liblapack-dev gfortran rustc' ; \ - if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ - apt-get update && apt-get install -y $ARM_DEP && apt-get clean ; \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && \ - rm -rf /var/lib/apt/lists/* ; \ - fi ; \ - pip3 install --no-cache-dir -r /psa_car_controller/requirements.txt && \ - apt-get remove -y $ARM_DEP 2> /dev/null ; \ - apt-get autoremove -y +RUN pip3 install --system --no-cache-dir -r /psa_car_controller/requirements.txt EXPOSE 5000 + +FROM debian:buster-slim +ARG PYTHON_DEP +WORKDIR /config ENV PSACC_BASE_PATH=/ PSACC_PORT=5000 PSACC_OPTIONS="-c -r --web-conf" PSACC_CONFIG_DIR="/config" -CMD /psa_car_controller/docker_files/init.sh +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/* +COPY . /psa_car_controller/ +CMD /psa_car_controller/docker_files/init.sh \ No newline at end of file From 6e02a504a234bad43411e8d55cc731761b3244a7 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Wed, 30 Jun 2021 00:36:30 +0200 Subject: [PATCH 14/15] add androguard --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 54e1202..71bad7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-plotly python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy' +ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-plotly python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy androguard' FROM debian:buster-slim AS builder ARG PYTHON_DEP From 3de2d60746b11f736bf81ed8e1b5e62ed8a5d4c9 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Wed, 30 Jun 2021 22:10:46 +0200 Subject: [PATCH 15/15] use log instead of print --- app_decoder.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app_decoder.py b/app_decoder.py index 5160105..cb65296 100755 --- a/app_decoder.py +++ b/app_decoder.py @@ -113,7 +113,6 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, psacc.connect(client_email, client_password) psacc.save_config(name=config_prefix + "config.json") res = psacc.get_vehicles() - print(f"\nYour vehicles: {res}") if len(res) == 0: Exception("No vehicle in your account is compatible with this API, you vehicle is probably too old...") @@ -122,12 +121,9 @@ def firstLaunchConfig(package_name, client_email, client_password, country_code, car = psacc.vehicles_list.get_car_by_vin(vehicle["vin"]) if car is not None and "short_label" in vehicle and car.label == "unknown": car.label = vehicle["short_label"].split(" ")[-1] # remove new, nouvelle, neu word.... - car.set_energy_capacity() - else: - print("Warning: Can't get car model for please check cars.json") psacc.vehicles_list.save_cars() - print(f"\nYour vehicles: {res}") + logger.info("\nYour vehicles: %s", res) # Charge control charge_controls = ChargeControls(config_prefix + "charge_config.json")