BMW ConnectedDrive Binding

You’ve now both bindings installed, this will cause conflicts. Go to Settings - Bindings and uninstall the official delivered BMW ConnectedDrive. After uninstall perform on restart of openHAB and check

  • if only one bmw binding is installed
  • your vehicle thing shows the additional channels

Cool, I did it exactly like you suggested - many thanks!

  • removed the official binding
  • restarted the OH
  • removed and created the car item again

I am now one step ahead and can see the channel and the value is “29.1”.

My python script delivers however 29.080 (higher precision) which makes a bit more sense because the value is changing slightly during the day. Is there any way to increase the precision?

Go to Settings - Items and select the Item holding soc-max. Click Add Metadata and select State Description. Now add in Pattern your desired precision e.g. %.3f kWh

2 Likes

That worked, many thanks for the hint and this excellent add-on!

Hello everyone and congratulations. I found the work done very interesting and I am successfully testing the binding.
I find an error for which I would like to ask you for help because I can not understand the meaning. Maybe some of you have happened to it or have already talked about it but if so, I couldn’t find where …
The error is this:
[WARN] [.core.thing.binding.BaseThingHandler] - Handler VehicleHandler tried updating the thing status although the handler was already disposed.

I just can give a guess here. Perhaps you created more than one Vehicle Thing after installation. It might happen a BMW response arrives after / during deletion of a Thing and in this case the above error occurs.

If it occurs one time after setup I would say you can ignore it. In case of multiple occurrences check Things in Settings, perhaps there’s still one in Deleting state.

I’ve installed now 3.1.0RC1 , everything is working fine but the soc-max is still not there. Will it be included when 3.1.0 is officially released?

I’m running 3.1.0 now and soc-max is also missing for me (BMW i3)

@ralf1234 @sdda
The additional values like soc-max are not part of official 3.1 release. During testing with the different 3.1 Milestones Jetty Http Engine throws errors when using the OAuth2 Authorization - currently I don’t know why this is happening.

So the feature is working in principle but Software isn’t ready for a release yet.
If you desperately need these values you’ve to uninstall the official binding an copy the snapshot from this post into your addons folder.

Hi!
I tried now this version. Everythings working fine, but the soc-max simply returns null…
In the log file is also nothing serious found. Maybe I first to drive or load to get this value filled?

OK, found my problem. Removing the binding in the UI was not enough. In the addons.cfg I still had an entry with all bindings including bmwconnecteddrive. After removing it and rebooting the raspberry it is working fine

1 Like

Hi guys,
great binding, had it up and running in 5 minutes!
Question: Would it be possible to create an automation that can start/stop charging based on the production of my solar panels? I have the readings of the panels and want to add an automation to start or stop charging. BMW connect doesn’t offer such a function, as far as I have seen, but it might be possible by changing the charging mode from scheduled to direct, or some other trick. Any experience or idea?

Depending on the wallbox you have (API available?) you can control it via this one.
I did it with the Easee home wallbox. In case you are interested:

In case you are using a different wallbox you may at least reuse some code snippets :slight_smile:

1 Like

I agree with @struppie ,
The wall box is probably the way to do it. I have a Keba wall box (+oh binding) that OH stops charging at ~80% as read from car depending on a switch in openhab ui.

I’ve contacted my wall box supplier to see if they have an api that can be used for this. Thanks for the advice!

Not sure if this has been discussed already but since Location type is used instead of latitude / longitude channels the “old” rule regarding the image of the car is not working anymore.
I’m a bit confused how to use the Location type in this rule? Maybe anyone who has changed the rule for the new location type?

I’m talking about this rule:

// Change Image according to Vehicle Status
rule "Image Status"
    when
        System started or
        Item i3ChargingStatus changed or
        Item i3Latitude changed or
		Item i3Longitude changed or
        Item i3CheckControl changed or
        Item i3LockStatus changed
    then
        if(i3ChargingStatus.state.toString == "Charging") {
            logInfo("Vehicle Image","Charging")
            i3ImageViewport.sendCommand("SIDE")
        } else if( (i3LockStatus.state.toString != "Secured") && (i3LockStatus.state.toString != "Locked") ) {
            logInfo("Vehicle Image","Doors not locked")
            i3ImageViewport.sendCommand("DRIVERDOOR")
        } else if(i3CheckControl.state.toString == "Active") {
            logInfo("Vehicle Image","Check Control Active")
            i3ImageViewport.sendCommand("DASHBOARD")
        } else {
            val latitudeNumber = i3Latitude.state as Number
            val longitudeNumber = i3Longitude.state as Number
            // Home Location Range - insert your Home Latitude / Longitude ranges
            if((1.23 < latitudeNumber.floatValue) && ( latitudeNumber.floatValue < 1.24) && (3.21 < longitudeNumber.floatValue) && (longitudeNumber.floatValue < 3.22) ) {
                logInfo("Vehicle Image","Home Location")
                i3ImageViewport.sendCommand("FRONT")
            } else {
                logInfo("Vehicle Image","Vehicle is away")
                i3ImageViewport.sendCommand("REAR")
            }    
        }
end

Please have a look in this post in this thread. It shows the settings how to place your charging window + departure time in order to stop charging. Start charging is reached with charge mode “IMMEDIATE_CHARGING”.

I agree with the first reactions to control this via your Wallbox. The above solution has some pitfalls:

  • If you’re on a trip this will impact charging on foreign charging stations
  • be careful on triggers - if it’s a cloudy day you’ll switch charging on/off too frequent

Here it is - Channel names changed but you should see the idea splitting the Location Channel:

            val latitudeNumber = Float::parseFloat(BMWi394hREX_Koordinaten.state.toString.split('\\,').get(0))
            val longitudeNumber = Float::parseFloat(BMWi394hREX_Koordinaten.state.toString.split('\\,').get(1))
            // Home Location Range - insert your Home Latitude / Longitude ranges
            if( (Math::abs(%YOUR_HOME_LAT%-latitudeNumber) < 0.003) && (Math::abs(%YOUR_HOME_LON%-longitudeNumber) < 0.003) ) {
                logInfo("Vehicle Image","Home Location")
                BMWi394hREX_FahrzeugAnsicht.sendCommand("FRONT")
            } else {
                BMWi394hREX_FahrzeugAnsicht.sendCommand("REAR")
            }    
1 Like

Great, it’s working perfectly! Thank you so much!

Hi Bernd,

while rebuilding my oH environment in oH3 i was happy to see that BMW Connected Drive finally got a binding, instead of the Python script.
I configured everything and was able to receive data for some days.
I don´t know exactly when but the binding stopped working in the last couple of days.

Here´s a log with the DEBUG level enabled:

2021-08-05 16:40:42.753 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:michael:320d' changed from UNINITIALIZED (DISABLED) to UNINITIALIZED
2021-08-05 16:40:42.784 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:michael:320d' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2021-08-05 16:40:42.786 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from OFFLINE (COMMUNICATION_ERROR): Bad Request to UNINITIALIZED
2021-08-05 16:40:42.800 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2021-08-05 16:40:47.327 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from UNINITIALIZED (DISABLED) to INITIALIZING
2021-08-05 16:40:47.336 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from INITIALIZING to UNKNOWN
==> /var/log/openhab/openhab.log <==
2021-08-05 16:40:52.497 [DEBUG] [internal.handler.ConnectedDriveProxy] - Authorization status 400 reason Bad Request
2021-08-05 16:40:52.639 [DEBUG] [internal.handler.ConnectedDriveProxy] - HTTP Error https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles - 400 - Bad Requestnull
2021-08-05 16:40:52.643 [DEBUG] [.handler.ConnectedDriveBridgeHandler] - ###### Discovery Troubleshoot Fingerprint Data - BEGIN ######
2021-08-05 16:40:52.644 [DEBUG] [.handler.ConnectedDriveBridgeHandler] - ### Discovery Result ###
2021-08-05 16:40:52.646 [DEBUG] [.handler.ConnectedDriveBridgeHandler] - {"url":"https://b2vapi.bmwgroup.com/webapi/v1/user/vehicles","status":400,"reason":"Bad Request","params":"null"}
2021-08-05 16:40:52.647 [DEBUG] [.handler.ConnectedDriveBridgeHandler] - ###### Discovery Troubleshoot Fingerprint Data - END ######
==> /var/log/openhab/events.log <==
2021-08-05 16:40:52.649 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Bad Request
2021-08-05 16:40:56.793 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:michael:320d' changed from UNINITIALIZED (DISABLED) to UNINITIALIZED
2021-08-05 16:40:56.817 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:conv:michael:320d' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)
2021-08-05 16:40:56.818 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from OFFLINE (COMMUNICATION_ERROR): Bad Request to UNINITIALIZED
2021-08-05 16:40:56.830 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'bmwconnecteddrive:account:michael' changed from UNINITIALIZED to UNINITIALIZED (DISABLED)

The log shows the way from enabling the bridge thing and disable it again.
The username and password are correct, i double checked and logged into the Connected Drive portal.
The region is configured as ROW.

Any ideas or should i create a Github issue?

kind regards
Michael