diff --git a/Dockerfile b/Dockerfile index 7020051..71bad7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +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 androguard' + +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 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 pip3 install --system --no-cache-dir -r /psa_car_controller/requirements.txt EXPOSE 5000 -RUN chmod +x /psa_car_controller/docker_files/init.sh + +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 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: 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") diff --git a/docker_files/init.sh b/docker_files/init.sh old mode 100644 new mode 100755 index 0abb4cb..db326bc --- 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 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 ] diff --git a/web/config_views.py b/web/config_views.py index ef3cdd9..7c2e3dd 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": "Citroë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( @@ -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 GB for United Kingdom", + "Example: FR for FRANCE or GB for Great Britain...", color="secondary", ) ]