BMW ConnectedDrive Binding

Just raised a Pull Request for the BMW ConnectedDrive Binding. It works fine on my i3 with Range Extender and I was able to get some test data for conventional Cars. So it shall work with all BMW Cars attached to ConnectedDrive.

In case of trouble there are 2 switches to generate anonymous debug information in the log in order to analyze problems. See Readme.md for the whole description.

Test Bundle, example setup and some rules are available

Your feedback is highly appreciated!

HABPanel Impression

7 Likes

I will try it with my 530e.
I am currently using python scripts to access connected drive, which works ok. However, I see the advantage of using this binding instead.

1 Like

Bernd, thank you so much for creating this BMW ConnectedDrive Binding.

I’ve used your test bundle to test it with my 318i F31 2019.
org.openhab.binding.bmwconnecteddrive-2.5.9-SNAPSHOT.jar
You’re documentation and examples are very clear and everything seems to work as it should, except the window status.

The state in the Vehicle Troubleshoot Fingerprint Data changes, but the item state connected to channel status#windows doesn’t change when a window is open. It stays on ‘Closed’.

I double-checked my items file and configuration in Paper UI but can’t find anything wrong there.
All other states that should work with my car and enabled services change correctly when something changes at the car (for example door status or lock status).

Hereby my Vehicle Troubleshoot Fingerprint Data (with the driver window left open):

2020-09-18 14:16:59.208 [WARN ] [rive.internal.handler.VehicleHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - BEGIN ######

2020-09-18 14:16:59.210 [WARN ] [rive.internal.handler.VehicleHandler] - ### Discovery Result ###

2020-09-18 14:16:59.215 [WARN ] [rive.internal.handler.VehicleHandler] - {"vehicles":[{"vin":"ANONYMOUS","model":"318i","driveTrain":"CONV","brand":"BMW","yearOfConstruction":2019,"bodytype":"F31","color":"MINERALGRAU 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":"ACTIVATED","lightFlash":"ACTIVATED","doorLock":"ACTIVATED","doorUnlock":"ACTIVATED","climateNow":"ACTIVATED","sendPoi":"ACTIVATED","remote360":"NOT_SUPPORTED","climateControl":"START_TIMER","chargeNow":"NOT_SUPPORTED","lastDestinations":"NOT_SUPPORTED","carCloud":"ACTIVATED","remoteSoftwareUpgrade":"NOT_SUPPORTED","climateNowRES":"NOT_SUPPORTED","climateControlRES":"NOT_SUPPORTED","smartSolution":"NOT_SUPPORTED","ipa":"NOT_SUPPORTED"}]}

2020-09-18 14:16:59.218 [WARN ] [rive.internal.handler.VehicleHandler] - ### Vehicle Status ###

2020-09-18 14:16:59.224 [WARN ] [rive.internal.handler.VehicleHandler] - {"vehicleStatus":{"mileage":25659,"remainingFuel":55.0,"remainingRangeElectric":0.0,"remainingRangeElectricMls":0.0,"remainingRangeFuel":794.0,"remainingRangeFuelMls":493.0,"maxRangeElectric":0.0,"maxRangeElectricMls":0.0,"maxFuel":0.0,"chargingLevelHv":0.0,"vin":"ANONYMOUS","updateReason":"VEHICLE_SHUTDOWN","updateTime":"2020-09-18T12:11:38+0000","doorDriverFront":"CLOSED","doorDriverRear":"CLOSED","doorPassengerFront":"CLOSED","doorPassengerRear":"CLOSED","windowDriverFront":"INTERMEDIATE","windowDriverRear":"CLOSED","windowPassengerFront":"CLOSED","windowPassengerRear":"CLOSED","trunk":"CLOSED","rearWindow":"CLOSED","hood":"CLOSED","doorLockState":"SECURED","parkingLight":"OFF","positionLight":"OFF","position":{"lat":-1.0,"lon":-1.0,"heading":-1,"status":"OK"},"internalDataTimeUTC":"2020-09-18T12:11:38","singleImmediateCharging":false,"vehicleCountry":"NL","DCS_CCH_Activation":"NA","DCS_CCH_Ongoing":false,"checkControlMessages":[],"cbsData":[{"cbsType":"OIL","cbsState":"OK","cbsDueDate":"2022-07","cbsDescription":"Next service due when the stated distance has been covered or by the specified date.","cbsRemainingMileage":29000},{"cbsType":"VEHICLE_CHECK","cbsState":"OK","cbsDueDate":"2022-07","cbsDescription":"Next visual inspection due when the stated distance has been covered or by the stated date.","cbsRemainingMileage":29000},{"cbsType":"BRAKE_FLUID","cbsState":"OK","cbsDueDate":"2022-01","cbsDescription":"Next change due at the latest by the stated date.","cbsRemainingMileage":0}]}}

2020-09-18 14:16:59.226 [WARN ] [rive.internal.handler.VehicleHandler] - ### Last Trip ###

2020-09-18 14:16:59.229 [WARN ] [rive.internal.handler.VehicleHandler] - {"lastTrip":{}}

2020-09-18 14:16:59.231 [WARN ] [rive.internal.handler.VehicleHandler] - ### All Trips ###

2020-09-18 14:16:59.234 [WARN ] [rive.internal.handler.VehicleHandler] - {"allTrips":{"avgElectricConsumption":{},"avgRecuperation":{},"chargecycleRange":{},"totalElectricDistance":{},"avgCombinedConsumption":{}}}

2020-09-18 14:16:59.236 [WARN ] [rive.internal.handler.VehicleHandler] - ### Charge Profile ###

2020-09-18 14:16:59.239 [WARN ] [rive.internal.handler.VehicleHandler] - {"destinations":[]}

2020-09-18 14:16:59.241 [WARN ] [rive.internal.handler.VehicleHandler] - ### Range Map Empty ###

2020-09-18 14:16:59.243 [WARN ] [rive.internal.handler.VehicleHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - END ######

Anything that I can do to fix this?

1 Like

Hi @Ronald,

thanks for delivering the exact data needed to debug this issue! I’m really thrilled! :+1:

I added your data to my unit tests and I observed the state “Intermediate” was dismissed.

Please check the new Release Candidate (as mentioned on top) if this is solving your issue.

1 Like

I just added the things and items via PaperUI just to test it.
Everything seems to work perfectly fine. All the items are populated with info.
The “control items” works fine as well.

Many thanks for your efforts!

1 Like

Hi @Daniel_Linder

Thanks for testing!
Do you have any Statistics regarding “Last Trip” and “Lifetime” available for your Car?

I’m searching for “broad test data” in order to support all kind of Cars.

Hello @weymann,

Thank you, your fix is working!
I’m really excited that with your binding I now can create rules to let OpenHab notify me when I locked the car when a window is left open, or when I leave the car unlocked (the functionality I really miss in the BMW app). So thanks again for all the effort you put in this project!

I have no intention to use the car service status data, but I think ‘Service Mileage’ is not working as it should. The state of the item is ‘- -’. The car dashboard says service is needed by 2022-01 or 29000 km.
In the Vehicle Troubleshoot Fingerprint Data I see different entries for “cbsRemainingMileage” with value 29000 but also 0.

Also I want to let you know the behaviour of the door and window state items. I think this is the behaviour as designed and for me It serves my purpose.
The state of the items seems to only reflect the last changed door/window. For example:
Car window driver front: open.
Car window passenger rear: half open (intermediate).
Car trunk: open.
Car door driverrear: open.

Item Door status state: ‘Driverrear Open’
Item Window Status state: ‘Driverfront Open’

The Vehicle Troubleshoot Fingerprint Data as it was in the above described situation:

2020-09-19 11:56:25.425 [WARN ] [rive.internal.handler.VehicleHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - BEGIN ######
2020-09-19 11:56:25.427 [WARN ] [rive.internal.handler.VehicleHandler] - ### Discovery Result ###
2020-09-19 11:56:25.431 [WARN ] [rive.internal.handler.VehicleHandler] - {"vehicles":[{"vin":"ANONYMOUS","model":"318i","driveTrain":"CONV","brand":"BMW","yearOfConstruction":2019,"bodytype":"F31","color":"MINERALGRAU 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":"ACTIVATED","lightFlash":"ACTIVATED","doorLock":"ACTIVATED","doorUnlock":"ACTIVATED","climateNow":"ACTIVATED","sendPoi":"ACTIVATED","remote360":"NOT_SUPPORTED","climateControl":"START_TIMER","chargeNow":"NOT_SUPPORTED","lastDestinations":"NOT_SUPPORTED","carCloud":"ACTIVATED","remoteSoftwareUpgrade":"NOT_SUPPORTED","climateNowRES":"NOT_SUPPORTED","climateControlRES":"NOT_SUPPORTED","smartSolution":"NOT_SUPPORTED","ipa":"NOT_SUPPORTED"}]}
2020-09-19 11:56:25.433 [WARN ] [rive.internal.handler.VehicleHandler] - ### Vehicle Status ###
2020-09-19 11:56:25.441 [WARN ] [rive.internal.handler.VehicleHandler] - {"vehicleStatus":{"mileage":25725,"remainingFuel":52.0,"remainingRangeElectric":0.0,"remainingRangeElectricMls":0.0,"remainingRangeFuel":814.0,"remainingRangeFuelMls":505.0,"maxRangeElectric":0.0,"maxRangeElectricMls":0.0,"maxFuel":0.0,"chargingLevelHv":0.0,"vin":"ANONYMOUS","updateReason":"VEHICLE_SHUTDOWN","updateTime":"2020-09-19T09:55:06+0000","doorDriverFront":"CLOSED","doorDriverRear":"OPEN","doorPassengerFront":"CLOSED","doorPassengerRear":"CLOSED","windowDriverFront":"OPEN","windowDriverRear":"CLOSED","windowPassengerFront":"CLOSED","windowPassengerRear":"INTERMEDIATE","trunk":"OPEN","rearWindow":"CLOSED","hood":"CLOSED","doorLockState":"SECURED","parkingLight":"OFF","positionLight":"OFF","position":{"lat":-1.0,"lon":-1.0,"heading":-1,"status":"OK"},"internalDataTimeUTC":"2020-09-19T09:55:06","singleImmediateCharging":false,"vehicleCountry":"NL","DCS_CCH_Activation":"NA","DCS_CCH_Ongoing":false,"checkControlMessages":[],"cbsData":[{"cbsType":"OIL","cbsState":"OK","cbsDueDate":"2022-07","cbsDescription":"Next service due when the stated distance has been covered or by the specified date.","cbsRemainingMileage":29000},{"cbsType":"VEHICLE_CHECK","cbsState":"OK","cbsDueDate":"2022-07","cbsDescription":"Next visual inspection due when the stated distance has been covered or by the stated date.","cbsRemainingMileage":29000},{"cbsType":"BRAKE_FLUID","cbsState":"OK","cbsDueDate":"2022-01","cbsDescription":"Next change due at the latest by the stated date.","cbsRemainingMileage":0}]}}
2020-09-19 11:56:25.443 [WARN ] [rive.internal.handler.VehicleHandler] - ### Last Trip ###
2020-09-19 11:56:25.445 [WARN ] [rive.internal.handler.VehicleHandler] - {"lastTrip":{}}
2020-09-19 11:56:25.447 [WARN ] [rive.internal.handler.VehicleHandler] - ### All Trips ###
2020-09-19 11:56:25.449 [WARN ] [rive.internal.handler.VehicleHandler] - {"allTrips":{"avgElectricConsumption":{},"avgRecuperation":{},"chargecycleRange":{},"totalElectricDistance":{},"avgCombinedConsumption":{}}}
2020-09-19 11:56:25.451 [WARN ] [rive.internal.handler.VehicleHandler] - ### Charge Profile ###
2020-09-19 11:56:25.453 [WARN ] [rive.internal.handler.VehicleHandler] - {"destinations":[]}
2020-09-19 11:56:25.454 [WARN ] [rive.internal.handler.VehicleHandler] - ### Range Map Empty ###
2020-09-19 11:56:25.456 [WARN ] [rive.internal.handler.VehicleHandler] - ###### BMW ConnectedDrive Binding - Vehicle Troubleshoot Fingerprint Data - END ######

If I can test anything else with your binding and my car to help you improve the binding, please let me know.

I’ve been fiddling with for a brief moment this afternoon.
The BMW connected service is not very reliable from Sweden I must say. When using BMW’s App, sending commands works at best “occasionally”.
This makes it a bit difficult to draw any conclusions…
However, I’ve experienced a lot of “retries and time outs” Today. This is probably due to BMW’s servers.
Also - I do not receive any data for the “Destinations” Items. How is this supposed to work? Does it pull info from the Navigation System?, i.e. is it dependant on me having set a destination i the car, and completed that for any data to be available?

Hi @Ronald,

Service
Your data fingerprint is showing this:

	{
			"cbsType": "OIL",
			"cbsDueDate": "2022-07",
			"cbsRemainingMileage": 29000
		},
		{
			"cbsType": "VEHICLE_CHECK",
			"cbsDueDate": "2022-07",
			"cbsRemainingMileage": 29000
		},
		{
			"cbsType": "BRAKE_FLUID",
			"cbsDueDate": "2022-01",
			"cbsRemainingMileage": 0
		}

Next Service is “Brake Fluid” in Jan 2022 without Mileage. Other 2 are scheduled for July 2022. For this data the next service is correctly shown.

But I think your Car Dashboard is also showing this correctly. It’s saying either next Service in Jan 2022 OR in 29.000 km - Service is needed what comes first. But it doesn’t say which Service is needed, right?

I think this is a good observation. Perhaps the service name is not so important. I’ll change it the same way your Dashboard is showing this, otherwise it leads to confusion.

Doors & Windows
During development I just wanted to see if “anything” is open. As info I added the first occurence.
But I see your point here. Doors and Windows are fixed elements in the data structure so I’ll provide a status for each Door and Window.

Give me some time to fix that.

Testing
You are testing this Bindig in a perfect way! Data is delivered so I see it’s working. But you are questioning the delivered data and this is what I need to eliminate misunderstandings.
Keep going! :+1:

1 Like

Hi @Daniel_Linder,

it’s not only Sweden, also from Germany I observe many problems. What I saw so far the request goes out fine but the state updates are sometimes unreliable. I applied a 10 sec update of the “Remote Execution State”. This is showing for me the best result - lower rates provides errors also in Germany.

Regarding Destinations and other Services please check your Thing Properties. I added this in the Readme.md of the Project. You can check for your Car what’s supported or not.

Hello @weymann,

Service
You are completely right about the service information.
The Car Dashboard shows at startup the first needed service; in Jan 2020 OR in 29.000 km.
Further in the car service menu (iDrive) the other mentioned information can be found.

Doors & Windows
This method is fine with me, I also only want to know if anything is open. But maybe someone wants a complete overview of all the door and window states.

BMW app & Connected drive website
Just to let you know: I also experience ‘some delay’ in status updates from- and commands to the car with the BMW app or Connected drive website. It usually works fine but with an delay from seconds to minutes.

Keep up the good work and thanks again!

Hi,
Thanks for the pointer - “LastDestinations” " is obviously not supported by my car.

It is reported in the BMW app though.

Hi,

right, last destinations will not work. But do you have some data for “last-trip” and “lifetime”?
Due to the fact that Statistcis is mentioned in Supported Services you should receive some values here.
I honestly don’t have test data from PHEV Vehicles so far so for me it’s intersting if the values the same as for my BEV_REX.

The binding does not provide me with any items for last-trip or lifetime.

I need to fix this!
Sending a Vehilce Fingerprint would be great. All personal data is anonymized.

Done! It should be in your inbox.

1 Like

Hi @Daniel_Linder

Please check the updated bundle & configuration in the test branch mentioned in the top post. You should have now Lifetime Statistics and Last Trip Statistics available for your Car.

Hi @Ronald,

I updated the bundle & configuration in the test branch mentioned in the top post.

Service
Should be aligned with the Car view. In status group you’ll see the earliest Date & lowest Mileage till next Service. The new service group is designed as list and with the next Switch you can scroll through all scheduled services.

Doors & Windows
In status group the overall state of Doors & Windows is reported. The new doors group gives detailed information about concrete Doors / Windows which are still open or in Intermediate state.

Please have a look.

Hi @weymann,
Beautiful, now I have “a lot” of information. Just need to figure out what to do with all this. :wink:
I just quickly added the new items from paperUI, to see what information is available.
I believe there must be a “factor” issue for the “longest Distance with one Charge”. I would say it must be 36 km, not 3.6…
lifetime

Anyways, many thanks and nice work.
I will spend some time removing my old pyton script method, and create textual configs for this binding. I have a feeling the liftetime “combined consumption” and “average power recuperation” is mixed up, compared to what I can read on screen in the car. (it is not possible to tell from the above screenshot, due to the rounding - but I’ll double check when I’ve created textual configs and can set the precision)

According to your Fingerprint this is the right data

		"chargecycleRange": {
			"communityAverage": 11.04,
			"communityHigh": 169.59,
			"userAverage": 23.74,
			"userHigh": 3.62,
			"userCurrentChargeCycle": 28.06
		}

userHigh shall reflect the highest distance with one charge. Did you reset the data on short term?