BMW ConnectedDrive Binding

Thx! It worked.

Now I only need to figure out how to start the remote services.

BR
Mathias

in my PR to the OH3 version I did implement an action that allows to access the charging-profile by rules / scripts. Compiled bundle and small example-script on github:

ā€“ edit: this link is outdated. More recent version is linked below ā€“

My latest changes (see post before) allow to do some cool things. I did create a rule that will monitor charging (status and batterylevel) that will send a charging-profile to the car that will cause the active charging-process to suspend whenever a predefined limit has been exceeded. I do own an i3 which does lack such feature (other brands do have, bmw says the i3 does not need it). Of course itā€™s not a must-have, but (not saying this is a major issue with the i3 which it is not) it might help to reduce battery-degredation a bit. (At least it makes you feel it does ;-))

val soc = (bmwBatterySoc.state as Number).intValue
val limit = (bmwChargelimit.state as Number).intValue
if ( soc >= limit ) {
  val status = bmwChargingStatus.state
  logInfo("charginglimit", "chargingStatus: {}", status)
  if (new StringType("Charging").equals(status)) {
    val profile = getActions("chargeprofile", "bmwconnecteddrive:bev:xxxxxx:WBY8P21000XXXXXXX")
    val now = new DateTimeType()
    val dateTime = now.getZonedDateTime()
    profile.setChargingMode(new StringType("DELAYED_CHARGING"))
    profile.setTimer3Departure(new DateTimeType(dateTime.minusMinutes(15)))
    profile.setTimer3Days(new StringListType())
    profile.setTimer1Enabled(OnOffType.OFF)
    profile.setTimer2Enabled(OnOffType.OFF)
    profile.setTimer3Enabled(OnOffType.ON)
    profile.setPreferredWindowStart(new DateTimeType(dateTime.minusHours(4).minusMinutes(15)))
    profile.setPreferredWindowEnd(new DateTimeType(dateTime.minusMinutes(15)))
    profile.send()

    val actions = getActions("xmppclient","xmppclient:xmppBridge:jabberde")
    actions.publishXMPP("xxxxxxxx@jabber.org","120Ah Charging-limit reached: "+limit+", SOC: "+soc)
  }
}

The icing on the cake is I get notified via xmpp whenever this happens :wink:

(I did create two additional items - one for the limit, one to switch it on or off. The rule is triggered by changes to the battery-state-of-charge and will only run if the switch is set to on.)

ā€“ edit: this script is outdated, please see link to more recent release in next post. New version makes use of standard java types instead of the OpenHAB ones ā€“

Finally I did find out how to properly annotate the Action-methods to pass java-standard datatypes in and out. That removes the need to create StringType, StringListType, OnOffType or DateTimeType.
For release-jar and sample script see:

Thanks for all your hard work! I love the charge level limit feature youā€™ve added although I havenā€™t tried it yet since we canā€™t really go anywhere right now in the UKā€¦ Just one thing I spotted; the example sitemap has i3OverrideEnabled but thereā€™s no example item for it, so I saw the error when I pasted everything into my config files. I made a pull request to add it :slightly_smiling_face:

1 Like

thanks Matt :slight_smile:
While I think I do well writing code - Iā€™m not good in writing the docs. So any contribution here is highly appreciated.
Situation here in Germany is simmilar. I do very few miles with my i3 these days so it was sitting there with full battery and it took more than a week until I had a chance to do a real test of my charging-limit-feature.

Hello,

is there .jar for OH3.0.1 already? I would like to try out the binding with my G31.

Alex

Yes, links to OH2 and OH3 jars are linked in the top post

1 Like

Hi all,
moved over to OH3 ā€¦

I had to change the thing from ā€œBEVā€ to ā€œbevā€ and also in all items channels to make it work.

Is this a mistake I made, or is OH more sensitive?!!?
Now everything works find !! Great Binding

Hi Michael,

right, if you ran 2.5 before this change is needed for OH3. openHAB maintainers requested it In the official review: Thing IDs shall be lower case
Unfortunately Iā€™m too lazy to apply all these changes back into 2.5 version ĀÆ\_(惄)_/ĀÆ

There are some smaller incompatibilities but thing, item and sitemap example files are up to date in the OH3 download folder in the top post.

Iā€™ve just install OH3 in preparation to migrating my setup from OH2. I never managed to get the binding to work on OH2, but installed it last night on my fresh OH3 install. After adding my account details the binding found my car. But itā€™s reporting as offline, which is very odd. Any suggestions or ideas why this would happen?
My account is reporting as online though.

I havenā€™t setup any logging yet, but will take a look at see if there is anything obvious.

Hi @Maximo,

yes, logging is necessary to analyze the problem. The section Troubleshooting in the Binding description shows how to setup debug log level and which messages shall show up. After this we can take a deeper look.

Hereā€™s my logfile. Seems to be the initial call thatā€™s causing the problem. As I said above though, all of the details relating to the car have been collected fine.

2021-03-24 22:51:02.613 [DEBUG] [internal.handler.ConnectedDriveProxy] - HTTP Error https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBSFV92000C581987/status - 400 - Bad Request{}
2021-03-24 22:51:02.614 [DEBUG] [ternal.handler.VehicleChannelHandler] - https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBSFV92000C581987/status - 400 - Bad Request{}
2021-03-24 22:51:02.615 [DEBUG] [ternal.handler.VehicleChannelHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - BEGIN ######
2021-03-24 22:51:02.615 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### Discovery Result ###
2021-03-24 22:51:02.617 [DEBUG] [ternal.handler.VehicleChannelHandler] - {"vehicles":[{"vin":"Anonymous","model":"M5","driveTrain":"CONV","brand":"BMW","yearOfConstruction":2011,"bodytype":"F10","color":"MONTE CARLO BLAU METALLIC","statisticsCommunityEnabled":false,"statisticsAvailable":false,"hasAlarmSystem":true,"dealer":{"name":"Anonymous","street":"Anonymous","postalCode":"Anonymous","city":"Anonymous","country":"Anonymous","phone":"Anonymous"},"breakdownNumber":"Anonymous","chargingControl":"NOT_SUPPORTED","vehicleFinder":"ACTIVATED","hornBlow":"NOT_SUPPORTED","lightFlash":"ACTIVATED","doorLock":"ACTIVATED","doorUnlock":"ACTIVATED","climateNow":"ACTIVATED","sendPoi":"ACTIVATED","remote360":"NOT_SUPPORTED","climateControl":"START_TIMER","chargeNow":"NOT_SUPPORTED","lastDestinations":"NOT_SUPPORTED","carCloud":"NOT_SUPPORTED","remoteSoftwareUpgrade":"NOT_SUPPORTED","climateNowRES":"NOT_SUPPORTED","climateControlRES":"NOT_SUPPORTED","smartSolution":"NOT_SUPPORTED","ipa":"NOT_SUPPORTED"}]}
2021-03-24 22:51:02.617 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### Vehicle Status ###
2021-03-24 22:51:02.618 [DEBUG] [ternal.handler.VehicleChannelHandler] - {}
2021-03-24 22:51:02.618 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### Last Trip ###
2021-03-24 22:51:02.619 [DEBUG] [ternal.handler.VehicleChannelHandler] - {"lastTrip":{}}
2021-03-24 22:51:02.619 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### All Trips ###
2021-03-24 22:51:02.619 [DEBUG] [ternal.handler.VehicleChannelHandler] - {"allTrips":{"avgElectricConsumption":{},"avgRecuperation":{},"chargecycleRange":{},"totalElectricDistance":{},"avgCombinedConsumption":{}}}
2021-03-24 22:51:02.620 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### Charge Profile ###
2021-03-24 22:51:02.620 [DEBUG] [ternal.handler.VehicleChannelHandler] - {"destinations":[]}
2021-03-24 22:51:02.621 [DEBUG] [ternal.handler.VehicleChannelHandler] - ### Range Map Empty ###
2021-03-24 22:51:02.624 [DEBUG] [ternal.handler.VehicleChannelHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - END ######

Ok, I see. Status isnā€™t returned so Thing is set to offline. Nevertheless you should be able to execute the Channel Remote Command with lightflash, doors lock/unlock and climate even if the Thing status is offline. In Service execution state you can follow the status. You can give it a first try first.

For ā€œolderā€ cars thereā€™s a legacy status update which seems not working in your case. I updated the the binding so please get the newest one from the top post openHAB3 link and give me some feedback if this works.

That seems to have done the trick, both my account and car are showing as online.

1 Like

i had problems with installing the binding under openhabian raspios Version. It didnā€™t work in any of the 3.x version (stable/milestone/snapshot). After many installations I found an old 3.0 Version under
update release candidate Ā· weymann/openhab-addons@d818269 Ā· GitHub and took [org.openhab.binding.bmwconnecteddrive-3.0.0-SNAPSHOT.jar
this was working and now I se under Things this binding and can configure it. Bute I get follwoing errors:

2021-04-06 11:27:38.752 [DEBUG] [internal.handler.ConnectedDriveProxy] - HTTP Error https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/statistics/allTrips - 400 - Bad Request{}
2021-04-06 11:27:38.753 [DEBUG] [rive.internal.handler.VehicleHandler] - https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/statistics/allTrips - 400 - Bad Request{}
2021-04-06 11:27:38.817 [WARN ] [internal.handler.ConnectedDriveProxy] - Auth Exception: java.io.EOFException: HttpConnectionOverHTTP@1a4dcc6::DecryptedEndPoint@13b2385{customer.bmwgroup.com/35.246.215.17:443<->/192.168.2.20:46076,OPEN,fill=-,flush=-,to=53/0}
2021-04-06 11:27:38.986 [DEBUG] [internal.handler.ConnectedDriveProxy] - HTTP Error https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/destinations - 400 - Bad Request{}
2021-04-06 11:27:38.987 [DEBUG] [rive.internal.handler.VehicleHandler] - https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/destinations - 400 - Bad Request{}
2021-04-06 11:27:39.100 [WARN ] [internal.handler.ConnectedDriveProxy] - Auth Exception: java.io.EOFException: HttpConnectionOverHTTP@4c219a::DecryptedEndPoint@2a01ba{customer.bmwgroup.com/35.246.215.17:443<->/192.168.2.20:46082,OPEN,fill=-,flush=-,to=52/0}
2021-04-06 11:27:39.335 [DEBUG] [internal.handler.ConnectedDriveProxy] - HTTP Error https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/image?view=FRONT&width=1024&height=1024 - 400 - Bad Request{view=view=[FRONT], width=width=[1024], height=height=[1024]}
2021-04-06 11:27:39.337 [DEBUG] [rive.internal.handler.VehicleHandler] - https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles/WBAJP31010BT73338/image?view=FRONT&width=1024&height=1024 - 400 - Bad Request{view=view=[FRONT], width=width=[1024], height=height=[1024]}
2021-04-06 11:27:39.415 [WARN ] [internal.handler.ConnectedDriveProxy] - Auth Exception: java.io.EOFException: HttpConnectionOverHTTP@a97bed::DecryptedEndPoint@7d044f{customer.bmwgroup.com/35.246.215.17:443<->/192.168.2.20:46084,OPEN,fill=-,flush=-,to=90/0}

might this a Problem of the ā€œoldā€ Version or a other Problem?
THX

Please check the top post. Thereā€™re links to most recent OH2.5 and OH3 bundles.

Youā€™re right - the one you used is too old. There was a bugfix in January fixing the authorization issue.

Hello,

today i recognized this warning in my logs:

20:40:32.277 [WARN ] [nternal.handler.VehicleChannelHandler] - ConnectedDrive Proxy isn't present

The generell informations seems to be updated (kilometers, range, etc.), but the pictures and the location of the car cannot be received:

This error is indicating a basic problem in the initialization. I think you can see this message repeatedly in your logs according to your refresh rate. So I would doubt that you really get fresh data.

In principle the Proxy isnā€™t avaialble if the config shows an error. Please check the Bridge status. If itā€™s offline stop it and start afterwards again. Then letā€™s see whatā€™s reported.

1 Like

Thanks you, after another restart it works fine again.