Skip to content

Commit a1a0d6f

Browse files
authored
Merge pull request #7 from zivillian/docker
add linux and docker support
2 parents 8a3632a + fedda5e commit a1a0d6f

File tree

7 files changed

+180
-3
lines changed

7 files changed

+180
-3
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: [zivillian]
4+
custom: ['https://paypal.me/zivillian']

.github/workflows/docker.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Get tag
18+
id: repository
19+
run: echo "tag=$(git describe --tags HEAD)" >> $GITHUB_OUTPUT
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
- name: Login to GitHub Container Registry
25+
uses: docker/login-action@v2
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@v4
32+
with:
33+
images: zivillian/ora2mqtt
34+
- name: Build
35+
uses: docker/build-push-action@v3
36+
with:
37+
platforms: linux/amd64,linux/arm64,linux/arm/v7
38+
push: true
39+
tags: zivillian/ora2mqtt:main
40+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/dotnet.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
submodules: recursive
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v2
20+
with:
21+
dotnet-version: 6.0.x
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
- name: Publish ora2mqtt Windows
25+
run: dotnet publish -c release -r win-x64 --sc ora2mqtt/ora2mqtt.csproj
26+
- name: Publish ora2mqtt Linux
27+
run: dotnet publish -c release -r linux-x64 --sc ora2mqtt/ora2mqtt.csproj
28+
- name: Publish ora2mqtt Linux ARM
29+
run: dotnet publish -c release -r linux-arm --sc ora2mqtt/ora2mqtt.csproj
30+
- name: Publish ora2mqtt Linux ARM64
31+
run: dotnet publish -c release -r linux-arm64 --sc ora2mqtt/ora2mqtt.csproj
32+
- uses: actions/upload-artifact@v2
33+
with:
34+
name: ora2mqtt-win-x64
35+
path: ora2mqtt/bin/release/net6.0/win-x64/publish
36+
- uses: actions/upload-artifact@v2
37+
with:
38+
name: ora2mqtt-linux-x64
39+
path: ora2mqtt/bin/release/net6.0/linux-x64/publish
40+
- uses: actions/upload-artifact@v2
41+
with:
42+
name: ora2mqtt-linux-arm
43+
path: ora2mqtt/bin/release/net6.0/linux-arm/publish
44+
- uses: actions/upload-artifact@v2
45+
with:
46+
name: ora2mqtt-linux-arm64
47+
path: ora2mqtt/bin/release/net6.0/linux-arm64/publish

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
2+
WORKDIR /app
3+
4+
COPY libgwmapi/ ./libgwmapi/
5+
COPY ora2mqtt/ ./ora2mqtt/
6+
ARG TARGETARCH
7+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
8+
RID=linux-musl-x64 ; \
9+
elif [ "$TARGETARCH" = "arm64" ]; then \
10+
RID=linux-musl-arm64 ; \
11+
elif [ "$TARGETARCH" = "arm" ]; then \
12+
RID=linux-musl-arm ; \
13+
fi \
14+
&& dotnet publish -c Release -o out -r $RID --sc ora2mqtt/ora2mqtt.csproj
15+
COPY openssl.cnf ./out/
16+
17+
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine
18+
WORKDIR /app
19+
COPY --from=build-env /app/out .
20+
COPY libgwmapi/Resources/gwm_root.pem /etc/ssl/certs/.
21+
ENV OPENSSL_CONF=/app/openssl.cnf
22+
23+
ENTRYPOINT ["/app/ora2mqtt", "-c", "/config/ora2mqtt.yml"]

README.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Falls du dabei Hilfe brauchst, kannst du auch einfach [einen Issue aufmachst](ht
1414

1515
Es gibt eine Kommandozeilenanwendung die unter Windows läuft und die aktuellen Werte auslesen und per MQTT veröffentlichen kann.
1616

17-
Im ersten Schritt muss die Konfigurationsdatei mit `ora2mqtt configure` erstellt werden. Anschließend kann die Anwendung mit `ora2mqtt run` oder einfach `ora2mqtt` gestartet werden. Damit sollten die aktuellen Werte im MQTT zu sehen sein.
17+
Im ersten Schritt muss die Konfigurationsdatei mit `ora2mqtt configure` erstellt werden. Dafür am besten einen zusätzlichen Account anlegen und das Auto für diesen Account freigeben. Anschließend kann die Anwendung mit `ora2mqtt run` oder einfach `ora2mqtt` gestartet werden. Damit sollten die aktuellen Werte im MQTT zu sehen sein.
1818

1919
Die Werte (SOC, Range und Odometer) können in [evcc](https://github.com/evcc-io/evcc/) mit der folgenden Konfiguration eingebunden werden:
2020

@@ -31,7 +31,7 @@ vehicles:
3131
timeout: 1m
3232
range:
3333
source: mqtt
34-
topic: GWM/<vin>/status/items/2011007/value
34+
topic: GWM/<vin>/status/items/2011501/value
3535
timeout: 1m
3636
odometer:
3737
source: mqtt
@@ -41,6 +41,59 @@ vehicles:
4141
4242
Ich habe das inzwischen auch ein paar Stunden laufen lassen, während ich mit dem Auto unterwegs war. Die Daten werden auch dann übermittelt, wenn die offizielle App nicht genutzt wird. Auch der Token Refresh war erfolgreich.
4343
44+
## Docker
45+
46+
Inzwischen gibt es auch einen Docker Container. Die config muss vorher mit `ora2mqtt configure` erstellt werden:
47+
48+
```bash
49+
docker run -d --restart=unless-stopped -v ./ora2mqtt.yml:/config/ora2mqtt.yml zivillian/ora2mqtt:latest
50+
```
51+
52+
# Datenpunkte
53+
54+
Folgende Datenpunkte kann ich auslesen:
55+
56+
| Datenpunkt | Beschreibung
57+
| ---------- | ------------
58+
| 2011501 | Reichweite in km
59+
| 2013021 | SOC
60+
| 2013022 |
61+
| 2013023 |
62+
| 2041142 | Ladevorgang aktiv
63+
| 2042071 |
64+
| 2042082 | bool Flag, nur aktiv wenn geladen wird (aber nicht immer)
65+
| 2078020 |
66+
| 2101001 | Reifendruck vl in kPa
67+
| 2101002 | Reifendruck vr in kPa
68+
| 2101003 | Reifendruck hl in kPa
69+
| 2101004 | Reifendruck hr in kPa
70+
| 2101005 | Reifentemperatur vl in °C
71+
| 2101006 | Reifentemperatur vr in °C
72+
| 2101007 | Reifentemperatur hl in °C
73+
| 2101008 | Reifentemperatur hr in °C
74+
| 2102001 |
75+
| 2102002 |
76+
| 2102003 |
77+
| 2102004 |
78+
| 2102007 |
79+
| 2102008 |
80+
| 2102009 |
81+
| 2102010 |
82+
| 2103010 | Kilometerstand in km
83+
| 2201001 | Innenraumtemperatur in zehntel °C
84+
| 2202001 | Klimaanlage an
85+
| 2208001 | Schloss offen
86+
| 2210001 | Fenster geschlossen vl
87+
| 2210002 | Fenster geschlossen vr
88+
| 2210003 | Fenster geschlossen hl
89+
| 2210004 | Fenster geschlossen hr
90+
| 2210010 |
91+
| 2210011 |
92+
| 2210012 |
93+
| 2210013 |
94+
| 2222001 |
95+
| 2310001 |
96+
4497
# How it started?
4598

4699
Bei evcc hat [jemand vorgeschlagen](https://github.com/evcc-io/evcc/discussions/9524#discussioncomment-6832420), dass man sich die App mal anschauen müsste...

openssl.cnf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openssl_conf = openssl_init
2+
3+
[openssl_init]
4+
ssl_conf = ssl_sect
5+
6+
[ssl_sect]
7+
system_default = system_default_sect
8+
9+
[system_default_sect]
10+
CipherString = DEFAULT@SECLEVEL=0

ora2mqtt/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
}
2929
catch (Exception ex)
3030
{
31-
Console.WriteLine(ex.Message);
31+
Console.WriteLine(ex);
3232
return -1;
3333
}

0 commit comments

Comments
 (0)