MyBMW Binding

Small improvement request: I can see the address as text in the raw data as well as in the app.

{“coordinates”:{“latitude”:52.190941,“longitude”:8.184755},"address":{“formatted”:“Kirchstraße 3, 49176 Hilter am Teutoburger Wald”},“heading”:345}

Would be great to get this into a channel as well.

I like this info, too. But thanks to the new Raw-data-channel I am able to copy this and other data into own items with this rule:

rule "BMW JSON values"
    Item BMW_Status_Raw changed
    val inMotion = transform("JSONPATH", "$.properties.inMotion", BMW_Status_Raw.state.toString)
    val fuelPercentage = transform("JSONPATH", "$.properties.fuelPercentage.value", BMW_Status_Raw.state.toString)
    val climateControl = transform("JSONPATH", "$.properties.climateControl.activity", BMW_Status_Raw.state.toString)
    val vehicleAddress = transform("JSONPATH", "$.properties.vehicleLocation.address.formatted", BMW_Status_Raw.state.toString)


I wanted to use a the JSON path Transformation in a profile but I was too stupid to do this or the profile-transformation is buggy.

Maybe supid but have you installed the JsonPath Transformation binding in UI?
Profile works with settings in picture

Yes, it is installed. The rule is working with JSONPATH.
I am maintaining all items in text files. Adding Profiles seems not to trigger the recreation of the item. But this topic might not belong here.

Hello! I’m trying to connect the MyBMW binding to my Z4. I use the MyBMW app, which works great, after the BMWConnected app only worked sporadically.

Currently, I’m trying to get the binding to connect to my account, and it’s not connecting. I’ve selected the Prefer MyBMW API after entering my account info. I’m sure it’s user error on my part. Logs show–

2022-01-18 10:55:30.817 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:f2bc880050' changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Forbidden
2022-01-18 10:55:30.820 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:f2bc880050:0b75b16c0c' changed from UNKNOWN to OFFLINE (BRIDGE_OFFLINE)
2022-01-18 10:55:35.861 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:f2bc880050' changed from OFFLINE (COMMUNICATION_ERROR): Forbidden to UNKNOWN
2022-01-18 10:55:35.865 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:f2bc880050:0b75b16c0c' changed from OFFLINE (BRIDGE_OFFLINE) to UNKNOWN
==> /var/log/openhab/openhab.log <==
2022-01-18 10:55:38.257 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
java.lang.NullPointerException: null
	at org.eclipse.jetty.util.UrlEncoded.decodeTo( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveProxy.codeFromUrl( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveProxy.updateToken( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveProxy.getToken( ~[?:?]
	at ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveProxy.get( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveProxy.requestVehicles( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveBridgeHandler.lambda$3( ~[?:?]
	at java.util.Optional.ifPresent( ~[?:?]
	at org.openhab.binding.bmwconnecteddrive.internal.handler.ConnectedDriveBridgeHandler.requestVehicles( ~[?:?]
	at java.util.concurrent.Executors$ ~[?:?]
	at ~[?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]
2022-01-18 10:56:17.075 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null
2022-01-18 10:57:26.413 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null
2022-01-18 10:58:35.756 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null
2022-01-18 10:59:45.045 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null

You have to create a mybmw account thing. There is no option to prefer mybmw API in the new binding. Your log is showing logs from the connecteddrive binding.

Thanks for the reply. The log was what I get when try to add my account information via setting up the Thing, using my account credentials. I’m able to log in to the BMW website via my credentials.

Yes I can confirm that login for US isn’t working anymore in BMW ConnecteDrive binding. In this thread we are discussing the first tests of the new MyBMW binding - the successor of the BMW ConnectedDrive binding which was introduced ~ 1.5 years ago. As you can see in the last posts many people are suffering due to more and more shutdowns of the old BMW API.

So please give this binding a try. Either download the jar from top post repo link or if you’re running OH3.2 install it from the Marketplace.

I double checked and US login is working correctly!

Fantastic-- thanks for the help! I’m still having some issues installing it, either through the marketplace (it tells me installation failed), and isn’t showing after manually putting the jar in the addons folder. I’m sure I have a configuration error someplace and will try to find it before I ask for more help.

As you can probably tell, I’m very new to openHAB, but so far, since installing it two days ago, I’ve interfaced it via Global Cache CC boxes with the 60 year old relays that run many of the lights in my house, and have it running on Astro events.

Edit: I figured it out-- strictly user error as I thought. Thanks again! It’s working perfectly!

1 Like

I’m right now starting to create my own pages and added a widged with some items related to my car on the overview page. I wonder whether it is possible to show the location of the car instead of GPS coordiates. When I tested Home Assistant a month ago it was super easy to add a card showing the location of the car.

My solution:.

Go to Settings - Pages and Create Map View. In settings add a marker with the coordinates item. Add a circle marker with coordinates as center and range-radius as circle. Save the page and the Map view is ready.

If you want this in a widget just one trick needed. Open the created map view and copy the url. In your overview create a Web Frame Card. Paste URL as adress and the Map is shown inside.

Great, many thanks. That did the trick.

One further enhancement request. I suggest to create a new channel ‘InMotion’ with Switch as type. As long as the car is changing coordinates between updates from the API the Switch should be ON. Once two updates in a row have the same coordinates, then the ‘InMotion’ switch channel should become off.

This would allow further logics to attach to this, i.e. if the car is not in motion and the doors are not locked, generate a notification to the user.

Unfortunately the BMW API (at least for my X1 PHEV) does not update the coordinates during driving. There are only certain events when the information are updated, like shutdown, start of charging, etc.

There is an own data field available (at least for my car):


I am already using it.

Did you try to set the refresh rate of your “car-thing” to 1 (minute)? Otherwise it is only refreshed every 5 minutes.

I would even like to refresh more often for being able to have a kind of geo fence for e.g. opening the garage door when the car is less than x meters away.

This issue is not related to the binding, but to the API or the car itself as the car or the API does not send this data. A 1m refresh period would just poll the same (not updated) information from the API more often.

I observed the same behavior like @schmidmuc Neither inMotion nor coordinates are changed during driving, regardless the poll intervall settings. Last update time only changes if some door states are changed or charging.
Sadly I didn’t found a hint so far in json reply if the car is supporting driving updates or not.

I have also been thinking of this. In my case I would like to disarm our alarm system (DSC1864) because when the alarm system is armed all the lights at our house are switched off, also in the garage. The problem is that how does OH know if the car is approaching the house or if it is leaving. Of course you don’t want OH to disarm the alarm system when you are leaving. So, I guess I would need to add some more logic.

I created a athome contact item. This will be set to closed when the distance from home is less than 10 meter and the doors are open or the car is not moving anymore. When athome is closed and the distance from home is more than 50 meters athome will change to open. I also use some global vars for distance from home, which I am setting to false if athome is closed.
With those item and vars it is easily possible to know if the car is approaching or leaving.

But to open the garage door the coordinates are still refreshed too seldom. Sometimes I would have to wait quite some time in front of the garage door until it would open automatically. And if I would set the geo fence too big I would also open the garage door even if I am just driving by.