Audi Carnet Binding (myAudi)

This binding will integrate the Audi Connect / my Audi services into openHAB. The binding will provide a bunch of status data (like milage, maintenance data, error indicators etc.), geo data for car position as well as some control functions.

Current status: Alpha - first implementation

  • Limited to the Audi Brand. Volkgswagen and Skoda seem to be possible, but not yet implemented - it’s much more than changing a strong even the API is very similar (prio 4)
  • A wide range of data channels is implemented, but no unit conversion so far (e.g. outdoorTemp is reported in Kelvin and not yet transformed into C, prio 3)
  • Geo position is received, but channel update doesn’t work yet (prio 2)
  • Prio 1 and for now a road blocker: Even the authorization is performed and successful it’s not possible to use the services beside lock/unlock, e.g. pre-heating, climater. I already checked several implementations, which also provide those functions, but so far not success (also I didn’t found a proof that they are working NOW)

Latest Download (DEV build, URL stays the same on Updates) and primarily README
provided AS IS and yes, sometimes it breaks functionality.

Installation:

  • copy the jar into OH’s addons folder
  • Go to Configuration:Things, press + and add the CarNet Account Thing
  • Enter myAudi credentials, account thing should get online
  • Now the Inbox should show any vehicle you registered in myAudi, if not run the discovery
  • Edit the thing configuration and set the SPIN (the same you use in the myAudi App)
  • The tvehicle thing goes ONLINE and after a few sec receives channel data

Channels:

  • Data channels: Will be dynamically created based on API results. Some of them show incorrect values, because a conversion is required (e.g. outDoor temp). Some of them should have better thing types (e.g. Switch instead of Number with 0/1). Some of them already work as expected :slight_smile:
  • Geo position: integrated, but channels are not yet updated properly
  • Lock/Unlock: Works if SPIN is available in thing config
  • A/C on/off/Window heat on/off, Pre-Heat on/off: Does not yet work, auth rejected

Please not that data is updated frequently, but not event based. Your could set the referesh interval in the thing configuration. In addition you could trigger manual updates.In addition you could request a manual update to refresh data by setting the update channel to ON. Be aware: I saw that they have a type of API limit, frequent polling might lock your account. There will be some testing and optimization to “know the limits”.

How you could help:

  • Please report here if you have any App, which is able to control functions exceeding what’s offered in the myAudi App
  • Verify the data channels and provide recommendations how to adjust the item type or where a conversion is needed
  • Perform changes to the car status and chek if they are properly reported with the next update
  • Provide links to meaningful pages, other implementations, which are not listed here with a brief description. I already have some stuff I’ll add here.

Known sources:

Disclaimer: The CarNet API is not officially documented nor does Volkswagen intend to enable “unofficial 3rd party Apps”. This means usage you be shutdown at any time or you could face unpredictable results.

Please be patient. Feedback and ideas are always welcome, but there is much work behind the scenes than you imaging beside that: it’s my spare time and I’m working on other bindings too (Shelly, MagentaTV, Gree, Apple-TV, Rachio), WhatsApp is deprecated ) :slight_smile:

I dtumbled across some posts regarding s Volkswagen binding, might be worth to have a look…

yes, you are referring to this one


but “of course” the VW We Connect API is not the same as the myAudi one. Nevertheless there might be overlaps (e.g. channel definitions, general stuff) so makes sense to check the code. So thx.

Could everyone else contribute knowing details on the myAudi API? I found some stuff on GitHub, some is out-dated, some does HTML parsing. I seems also Setze Differenz between US and EU APIs, which makes it even more intransparent.

Ok, I started on the CarNet binding and already made progress

Bildschirmfoto 2020-02-19 um 01.24.11

2 Likes

I’d be interested in helping test this!

ok, great. Which type of Audi or VW do you have? Electrical or gas?
Currently I’m focusing on Audi/myAudi. VW seems to have the same API on different URLs(don’t mix with We-Connect, tat’s something completely different and not compatible to the myAudi API) with some minor inconsistencies, which could be handled dynamically.

I’m already reading 25 status values and working on creating the channels dynamically. That works, but due to the high number of channels (even not mapping all values) I want to group the, and that doesn’t work so far. Once I managed this I could provide a first build.

1 Like

Great! I have a 2016 TT - Gas.

Something I’ve struggled with this knowing what data/features are available for what model year with Audi Connect. I bought this used a year ago and had been using my phone as a hot spot to connect my Audi to the internet while I was in the car, but now trying to get a SIM set up.

I’m also willing to test this binding. I have a Q3 (2019)

Sounds interesting. I have an A4 Allroad (2018).

Good morning, here is the very first build:
https://github.com/markus7017/myfiles/blob/master/carnet/org.openhab.binding.carnet-2.5.5-SNAPSHOT.jar?raw=true

Please have 0 expectations.

  • Currently only Audi is supported (mine is a Gas car)
  • Supported countries are DE, BE (let me know if you want others)
  • Currently only status values are implemented, no control functions
  • Maybe not all status values

Installation

  • enable logging in OH console: log:set TRACE org.openhab.binding.carnet
  • copy the jar into your addons folder
  • create a CarNet Account Thing (with + in the Inbox oder Things view), enter credentials
  • this should bring a new thing getting ONLINE
  • Run the discovery from the Inbox, this brings in the Vehicle things
  • enjoy tons of channels, select those you need :wink:

Check log for errors and report them here.
fyi: The channel structure might change from build to build, it’s a alpha version!

First step should be to verify if the channels make sense, show proper values, the item type could be changed to be more meaningful (e.g. a Switch rather than 0/1 number).

Include your car model in any post.

1 Like

Thanks for the first build!
Do we need to be on 2.5.5-snapshot? I saw that I was still on 2.5.3, so updating now first to 2.5.4

No, it tuns on 2.5.x

1 Like

my thing stays on ‘unknown’ status

2020-05-17 11:23:31.232 [DEBUG] [inding.carnet.internal.api.CarNetApi] - Initializing CarNet API
2020-05-17 11:23:31.271 [hingStatusInfoChangedEvent] - ‘carnet:account:myAudi’ changed from UNINITIALIZED to INITIALIZING
2020-05-17 11:23:31.300 [DEBUG] [inding.carnet.internal.api.CarNetApi] - Setting up CarNet API for brand Audi (BE), user wxxxxxxx@mail.com
2020-05-17 11:23:31.302 [hingStatusInfoChangedEvent] - ‘carnet:account:myAudi’ changed from INITIALIZING to UNKNOWN
2020-05-17 11:23:31.319 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP POST https://msg.audi.de/fs-car/core/auth/v1/Audi/BE/token, parms=, data={Content-Type=application/x-www-form-urlencoded}, headers=grant_type=password&username=wxxxxxxx@mail.com&password=password
2020-05-17 11:23:31.930 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP Response: {
2020-05-17 11:23:31.938 [TRACE] [nternal.handler.CarNetAccountHandler] - Properties updated
2020-05-17 11:23:31.942 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP GET https://msg.audi.de/fs-car/usermanagement/users/v1/Audi/BE/vehicles, parms=, data={Authorization=AudiAuth 1 MEOdr1bHti8uI/MJ47sEJav3MKMg4D4q/061sapHOYoD0Wf4bY7Y, User-Agent=okhttp/2.3.0, X-App-Name=eRemote, X-App-Version=1.0.0}, headers=
2020-05-17 11:23:32.081 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP Response: {“userVehicles”:{“vehicle”: [“WAxxxxxxxxxxxxxxx”]}}
2020-05-17 11:23:32.090 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP GET https://msg.audi.de/fs-car/promoter/portfolio/v1/Audi/BE/vehicle//WAxxxxxxxxxxxxxxx/carportdata, parms=, data={Authorization=AudiAuth 1 MEOdr1bHti8uI/MJ47sEJav3MKMg4D4q/061sapHOYoD0Wf4bY7Y, User-Agent=okhttp/2.3.0, X-App-Name=eRemote, X-App-Version=1.0.0}, headers=
at org.openhab.binding.carnet.internal.api.CarNetApiResult.fillFromResponse(CarNetApiResult.java:86) ~[?:?]
at org.openhab.binding.carnet.internal.api.CarNetApiResult.(CarNetApiResult.java:55) ~[?:?]
at org.openhab.binding.carnet.internal.api.CarNetApi.request(CarNetApi.java:207) ~[?:?]
at org.openhab.binding.carnet.internal.api.CarNetApi.httpGet(CarNetApi.java:164) ~[?:?]
at org.openhab.binding.carnet.internal.api.CarNetApi.getVehicleDetails(CarNetApi.java:106) ~[?:?]
at org.openhab.binding.carnet.internal.handler.CarNetAccountHandler.initializeThing(CarNetAccountHandler.java:118) ~[?:?]
at org.openhab.binding.carnet.internal.handler.CarNetAccountHandler.lambda$0(CarNetAccountHandler.java:96) ~[?:?]
2020-05-17 11:24:00.154 [DEBUG] [inding.carnet.internal.api.CarNetApi] - Setting up CarNet API for brand Audi (BE), user wxxxxxxx@gmail.com
2020-05-17 11:24:00.159 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP POST https://msg.audi.de/fs-car/core/auth/v1/Audi/BE/token, parms=, data={Content-Type=application/x-www-form-urlencoded}, headers=grant_type=password&username=wxxxxxxx@mail.com&password=password
2020-05-17 11:24:00.840 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP Response: {
2020-05-17 11:24:00.845 [TRACE] [nternal.handler.CarNetAccountHandler] - Properties updated
2020-05-17 11:24:00.849 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP GET https://msg.audi.de/fs-car/usermanagement/users/v1/Audi/BE/vehicles, parms=, data={Authorization=AudiAuth 1 xsPqXw0C1HMCDy+oGb5nFPrsNItvbn0F8eCde3zpWuigfgjzZ45x, User-Agent=okhttp/2.3.0, X-App-Name=eRemote, X-App-Version=1.0.0}, headers=
2020-05-17 11:24:00.991 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP Response: {“userVehicles”:{“vehicle”: [“WAxxxxxxxxxxxxxxx”]}}
2020-05-17 11:24:00.994 [TRACE] [inding.carnet.internal.api.CarNetApi] - HTTP GET https://msg.audi.de/fs-car/promoter/portfolio/v1/Audi/BE/vehicle//WAxxxxxxxxxxxxxxx/carportdata, parms=, data={Authorization=AudiAuth 1 xsPqXw0C1HMCDy+oGb5nFPrsNItvbn0F8eCde3zpWuigfgjzZ45x, User-Agent=okhttp/2.3.0, X-App-Name=eRemote, X-App-Version=1.0.0}, headers=

Same for me. After an obviously successful login (VIN on the console output is the right), the Thing status stays on UNKNOWN and the console output I find looks like this:

==> /var/log/openhab2/openhab.log <==
2020-05-17 11:27:36.876 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 11 path $.error
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:888) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:853) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:802) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:774) ~[?:?]
	at org.openhab.binding.carnet.internal.api.CarNetApiResult.fillFromResponse(CarNetApiResult.java:86) ~[?:?]
	at org.openhab.binding.carnet.internal.api.CarNetApiResult.<init>(CarNetApiResult.java:55) ~[?:?]
	at org.openhab.binding.carnet.internal.api.CarNetApi.request(CarNetApi.java:207) ~[?:?]
	at org.openhab.binding.carnet.internal.api.CarNetApi.httpGet(CarNetApi.java:164) ~[?:?]
	at org.openhab.binding.carnet.internal.api.CarNetApi.getVehicleDetails(CarNetApi.java:106) ~[?:?]
	at org.openhab.binding.carnet.internal.handler.CarNetAccountHandler.initializeThing(CarNetAccountHandler.java:118) ~[?:?]
	at org.openhab.binding.carnet.internal.handler.CarNetAccountHandler.lambda$0(CarNetAccountHandler.java:96) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_252]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_252]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 11 path $.error
	at com.google.gson.stream.JsonReader.nextString(JsonReader.java:825) ~[?:?]
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:401) ~[?:?]
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:389) ~[?:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[?:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[?:?]
	... 18 more

==> /var/log/openhab2/events.log <==

try new build (same URL), this should show the error message (causing the exception)

1 Like

I quickly replaced the jar via my phone and the thing is online now (i have to look in the logs to see if this new jar solved it, of if it was a matter of time). I was also able to add the vehicle. I’ll have a look later today to all channels.

Quick look to the channels: I need to select a profile, but the drop down is empty. The channel for VIN was working out of the box. I normally use textual config, so maybe I’m missing something (Will try text config this evening)

New jar seems to be working. CarNet Thing was online, car has been discovered and appeared in the inbox and has 1 channel for VIN. In the Logs I see many more measurements, like tire pressure, window / door lock status etc.

you beed to reload the page, those channels are created dynamically :wink:

Hi @markus7017,
even after reloading the page several times, there are no additional channels beside VIN. On the log file there is a long list of debug entries, showing fetched information from the car and an obviously unsuccessful attempt to assign to a not existing channel.

2020-05-18 20:32:57.965 [INFO ] [nternal.handler.CarNetVehicleHandler] - Updating WAUZZxxxxxxxxxx: KILOMETER_STATUS=43182 (channel status#kilometerStatus)
2020-05-18 20:32:57.968 [DEBUG] [nternal.handler.CarNetVehicleHandler] - Channel status#kilometerStatus not found

Yesterday I also saw the channels, and after I did some reconfig, they were gone. But now, after saving the config again, all channels appear again.

I already did the textual config for the carNet account :slight_smile:
Thing carnet:account:myAudi "myAudi Account" @ "Audi" [ user="wxxxxxx@mail.com", password="password", brand="Audi", country="BE"]

The vehicle is configured via paperUI and the items by textual config (can’t select profile in paperUI, and in textual config, this is not an issue)

First data is coming… :slight_smile:

will test all other channels later