Skip to content

BMW CarData Binding ​

This binding integrates BMW and MINI vehicles via BMW CarData, the official service of the BMW Group that provides the telematic data of a vehicle to its owner.

The binding receives the data in two ways:

  • Streaming: The CarData streaming service pushes the data of all vehicles of the account as soon as a vehicle reports it. This is the preferred way to keep the data up to date.
  • API requests: The CarData API is read periodically and after stream outages for the current values of all channels. The API allows 50 requests per day for all vehicles of an account, so the binding uses it sparingly, see API Requests.

BMW CarData provides read-only access, the vehicles cannot be controlled with this binding. BMW CarData is currently only available in some regions; check the CarData section of the MyBMW or MINI customer portal of your country.

Supported Things ​

  • account: Bridge representing the BMW CarData client of a customer account.
  • vehicle: A vehicle mapped to the account, identified by its VIN.

Prerequisites ​

Before the binding can be used, a CarData client has to be created in the customer portal:

  1. Log in to the MyBMW or MINI customer portal and open the vehicle overview.
  2. Open the BMW CarData section and create a client ID.
  3. Subscribe the client to both CarData API and CarData Streaming. Request the access to the CarData API explicitly (German portal: "Zugang zur CarData API beantragen"); enabling streaming alone is not sufficient. Enable one subscription at a time and check after a minute that both are still active, as the portal may reset them.
  4. In the streaming configuration of the portal, select the data that shall be streamed. Only the data selected there is pushed by the stream.

If the account goes OFFLINE (CONFIGURATION_ERROR) because BMW does not accept the client ID, check the client ID and that both subscriptions are active. The binding then stops trying; changing the configuration, or disabling and enabling the account, starts a new authorization. The DEBUG log shows BMW's error, e.g. invalid_request.

Discovery ​

After the account has been authorized, the vehicles mapped to the account as primary user are discovered. A discovery scan costs one request of the daily API quota, so it only runs automatically after authorization while the account has no vehicle Things. Discovered vehicles are labeled with their brand and model, which costs one more request per vehicle once; a vehicle Thing created from the result reuses that data. Known brands are shown with their usual name, e.g. BMW_I as BMW; the brand property keeps the value reported by BMW. If BMW explicitly reports a vehicle as not telematics capable, its label says so. BMW does not document this flag, so such a vehicle is still offered: it may not send any data. Further scans can be started manually from the Inbox.

Thing Configuration ​

account Bridge Configuration ​

NameTypeDescriptionDefaultRequiredAdvanced
clientIdtextThe client ID created in the CarData section of the portalN/Ayesno
streamingbooleanReceive the data pushed by the CarData streaming servicetruenono
streamModetextdirect connects to BMW, bridge receives the stream from the bmw-mqtt-bridgedirectnono
mirrorToBrokerbooleanRepublish the direct stream to the local MQTT broker, see Mirroring the Streamfalsenoyes
mirrorRetainbooleanPublish the mirrored stream messages retained, see Mirroring the Streamfalsenoyes
brokerHosttextHost of the local MQTT broker, required in bridge mode and for mirroringN/Anoyes
brokerPortintegerPort of the local MQTT broker1883noyes
brokerSecurebooleanConnect to the local MQTT broker with TLSfalsenoyes
brokerUsernametextUser name for the local MQTT brokerN/Anoyes
brokerPasswordtextPassword for the local MQTT brokerN/Anoyes
topicPrefixtextPrefix of the bridge topics (LOCAL_PREFIX of the bridge)bmw/noyes
refreshIntervalintegerHours between refreshes of all vehicle data via the API, 0 disables them6nono
requestBudgetintegerMaximum number of API requests in 24 hours (1 to 50)40noyes

The broker parameters are only used in bridge mode and for mirroring.

Stream Modes ​

BMW allows only one connection to the CarData stream per account. A second connection with the same account, e.g. from another smart home system, MQTT Explorer or evcc, disconnects the first one, so both keep reconnecting.

  • Direct (streamMode=direct): The binding connects to the BMW streaming service itself. This needs no additional software, but no other tool can use the stream of the account at the same time.
  • Bridge (streamMode=bridge): The bmw-mqtt-bridge holds the connection to BMW and republishes the unmodified stream messages to a local MQTT broker, on <prefix>raw/<VIN>, and its connection state on <prefix>status. The binding subscribes to these topics and does not connect to the BMW streaming service, but still uses the CarData API with its own authorization. Other tools, e.g. evcc, can read the same topics, so all of them share the single stream connection.

Mirroring the Stream ​

In direct mode, openHAB holds the only stream connection of the account. With mirrorToBroker=true, the binding republishes the stream to the local MQTT broker configured by the broker parameters, so that other tools, e.g. evcc, can use it without running the bmw-mqtt-bridge. The topics are those of the bmw-mqtt-bridge, so existing consumers of the bridge, and this binding in bridge mode, can read the mirror unchanged:

TopicPayloadRetained
<prefix>raw/<VIN>Every stream message, unmodified as received from BMWif mirrorRetain
<prefix>statusState of the BMW stream connection: {"connected":true,"timestamp":<seconds since epoch>}yes

Like the bmw-mqtt-bridge with its default MQTT_RETAIN=0, the stream messages are not retained by default. With mirrorRetain=true, a consumer receives the last message of each vehicle as soon as it subscribes, however old it is, e.g. after the vehicle has been parked for days.

The last will of the mirror sets <prefix>status to {"connected":false}, so consumers notice when openHAB stops. Like the bmw-mqtt-bridge with its default STATUS_STABLE_DELAY, a disconnect from BMW is only published once it lasts for five seconds, so short drops of the connection do not let the state flap. When openHAB stops the stream on purpose, e.g. for a new authorization, the disconnect is published right away. After openHAB starts, the state is published once the state of the stream is known. The mirror reconnects to the local broker on its own; while the broker is not reachable, messages are dropped and the status description of the account shows this, but the stream and the channels are not affected. Mirroring is ignored in bridge mode, as the bridge already publishes the stream.

While openHAB is down or restarting, consumers of the mirror receive no data. If other tools need the stream independent of openHAB, run the bmw-mqtt-bridge and use bridge mode instead.

API Requests ​

BMW allows 50 requests to the CarData API per account and day, reset at midnight UTC, shared by all vehicles and all tools using the account (see BMW's additional information on the CarData API). The stream is not affected by this limit, so the binding uses the API only to complete the stream data:

  • When a vehicle goes ONLINE after its start, after the start of the account or after a new authorization, its current values are read once, one request. Later status changes, e.g. when the account was offline for a moment, do not read it again; if the request budget is used up at that time, the vehicle is read at the next periodic refresh.
  • Every refreshInterval hours, the current values of all vehicles are read, one request per vehicle.
  • When the stream was interrupted for five minutes or more, the values are read again after the reconnect, as the stream does not replay missed values. This catch-up runs at most every 30 minutes.
  • When a read fails on BMW's side (e.g. HTTP 502) or times out, it is repeated once after 15 minutes for the affected vehicles. While the stream is connected, such a failure does not set the vehicle OFFLINE, as the stream keeps its values up to date.
  • The static vehicle data shown as Thing properties is read once per vehicle, and the binding sets up its own telematic data container named openHAB on first use, which costs a few requests. A vehicle goes ONLINE once its static data is known; if it cannot be read, e.g. while the request budget is used up, the vehicle stays OFFLINE and the binding tries again after 15 minutes. If BMW no longer accepts the container, e.g. because it was deleted, the binding sets up a new one at the next read. The same happens once after an update of the binding that reads other data points. BMW allows 10 containers per customer; if all are used by other tools, the vehicles report this, and one has to be deleted.
  • The vehicle image is read once per vehicle, and only when an item is linked to the status#image channel. Like the static data, it is kept, so it costs no further requests after a restart; if it cannot be read, e.g. while the request budget is used up, the binding tries again after 15 minutes. It does not retry failures that do not pass by themselves, e.g. when BMW has no image for the vehicle.
  • If BMW does not provide the data of a vehicle to the client, e.g. because it is not mapped to the account as primary user, the vehicle goes OFFLINE (CONFIGURATION_ERROR) and is no longer read; disable and enable the Thing once this is fixed.

The binding counts its requests over a rolling 24 hours per client ID, also across restarts and when the account thing is recreated, and sends at most requestBudget requests. Counting over a rolling 24 hours is stricter than BMW's daily reset, so the binding slows down before BMW's limit is reached and does not use up the whole quota right after midnight UTC. When the budget is used up, or BMW reports its limit as reached, the binding pauses its requests and shows this in the status description of the account; the stream keeps working. Keep a reserve below 50 if other tools use the same account.

Authorization ​

The binding is authorized with the OAuth device flow:

  1. Add the account bridge with the client ID.
  2. The bridge goes OFFLINE (AUTHORIZATION_PENDING) and its status description links to the authorization page at http(s)://<your openHAB>:<port>/bmwcardata.
  3. The page shows, for every account waiting for authorization, a button to the BMW portal, the same link as a QR code to scan with your phone, and the code to confirm.
  4. Log in with your BMW or MINI account and confirm the code. The BMW portal opens in the tab of the page, so you can close it once you have confirmed, and you are back where you opened the page.
  5. The bridge goes ONLINE within a few seconds.

The page is shown in the language of the browser if the binding has a translation for it, and otherwise in the language of openHAB.

The tokens are stored encrypted by openHAB's OAuth client service and renewed automatically. If it expires or is revoked, the authorization page shows a new link and code.

vehicle Thing Configuration ​

NameTypeDescriptionDefaultRequiredAdvanced
vintextThe 17 character vehicle identification numberN/Ayesno
dynamicChannelsbooleanCreate channels for received data without predefined channeltruenoyes

Channels ​

All channels are read-only. A channel is only updated if the vehicle reports the corresponding data and, for streaming, if the data has been selected in the customer portal.

When the static vehicle data is known, the channels that do not apply to the vehicle are removed:

  • For an electric vehicle (drive train BEV), the fuel channels, the total range, the engine state and the electric share of a trip.
  • For a combustion vehicle (drive train CONV), the charging, high-voltage battery and electric range channels and the electric share of a trip.
  • The sunroof channels, if BMW reports the vehicle has no sunroof.

The navigation channels are always kept: the location comes from the telematics unit, and BMW's hasNavi flag, shown as the hasNavigation property, is also reported as false for vehicles with a navigation system.

Plug-in hybrids (PHEV) and vehicles with another or no drive train keep all drive related channels. BMW does not document the values, so the binding only acts on those seen on real vehicles; the reported values are shown as Thing properties. Removed channels are added again once the vehicle has the corresponding features, e.g. after the VIN was changed to another vehicle; the static data of the new VIN is read for that.

ChannelTypeDescriptionAdvanced
status#door-lockSwitchWhether all doors are locked (ON)no
status#door-lock-stateStringReported lock state of the doors (LOCKED, SECURED, SELECTIVELOCKED, UNLOCKED)yes
status#trunkContactWhether the trunk is openno
status#hoodContactWhether the hood is openno
status#trunk-lockedSwitchWhether the trunk is lockedno
status#door-front-driverContactWhether the front driver door is openno
status#door-front-passengerContactWhether the front passenger door is openno
status#door-rear-driverContactWhether the rear driver side door is openno
status#door-rear-passengerContactWhether the rear passenger side door is openno
status#window-front-driverContactWhether the front driver window is open, also if partly openno
status#window-front-driver-stateStringReported state of the front driver window (CLOSED, INTERMEDIATE, OPEN)yes
status#window-front-passengerContactWhether the front passenger window is open, also if partly openno
status#window-front-passenger-stateStringReported state of the front passenger window (CLOSED, INTERMEDIATE, OPEN)yes
status#window-rear-driverContactWhether the rear driver side window is open, also if partly openno
status#window-rear-driver-stateStringReported state of the rear driver side window (CLOSED, INTERMEDIATE, OPEN)yes
status#window-rear-passengerContactWhether the rear passenger side window is open, also if partly openno
status#window-rear-passenger-stateStringReported state of the rear passenger side window (CLOSED, INTERMEDIATE, OPEN)yes
status#rear-windowContactWhether the rear window is openno
status#sunroofContactWhether the sunroof is open or tiltedno
status#sunroof-stateStringReported overall state of the sunroofyes
status#movingSwitchWhether the vehicle is movingno
status#ignitionSwitchWhether the ignition is onyes
status#engineSwitchWhether the engine is runningno
status#deep-sleepSwitchWhether the deep sleep mode is activeyes
status#battery-voltageNumber:ElectricPotentialVoltage of the 12V batteryyes
status#battery-socNumber:DimensionlessState of charge of the 12V batteryyes
status#last-updateDateTimeTime of the most recent data of the vehicleno
status#imageImagePicture of the vehicle, retrieved only while an item is linkedno
range#mileageNumber:LengthTotal distance travelledno
range#totalNumber:LengthTotal remaining rangeno
range#electricNumber:LengthRemaining electric rangeno
range#electric-charging-forecastNumber:LengthPredicted electric range during chargingyes
range#electric-targetNumber:LengthElectric range at the target state of chargeno
range#fuel-levelNumber:DimensionlessFill level of the fuel tankno
range#remaining-fuelNumber:VolumeAmount of fuel in the tankno
charge#socNumber:DimensionlessState of charge of the high-voltage batteryno
charge#target-socNumber:DimensionlessState of charge at which charging stopsno
charge#statusStringCharging stateno
charge#pluggedSwitchWhether a charging cable is plugged in (see below)no
charge#powerNumber:PowerCurrent charging powerno
charge#time-remainingNumber:TimeEstimated time until charging is completedno
charge#ac-currentNumber:ElectricCurrentCurrent AC charging currentyes
charge#ac-voltageNumber:ElectricPotentialCurrent AC charging voltageyes
charge#ac-limitNumber:ElectricCurrentSelected limit of the AC charging currentyes
charge#ac-limit-minNumber:ElectricCurrentLowest limit of the AC charging current that can be selectedyes
charge#ac-limit-maxNumber:ElectricCurrentHighest limit of the AC charging current that can be selectedyes
charge#phasesStringNumber of phases used for chargingyes
charge#methodStringCharging method and plug typeyes
charge#portStringWhether a charging plug is connected to the charging portyes
charge#predicted-socNumber:DimensionlessPredicted state of charge at the end of chargingyes
charge#min-target-socNumber:DimensionlessMinimum state of charge requested for smart chargingyes
charge#time-to-fullNumber:TimeEstimated time until the battery is fully chargedyes
charge#modeStringCurrent charging modeyes
charge#end-reasonStringReason why the last charging endedyes
charge#last-resultStringResult of the last chargingyes
charge#cable-lockStringLock state of the charging cableyes
charge#flapContactWhether the charging flap is openyes
charge#flap-lockedSwitchWhether the charging flap is lockedyes
battery#capacityNumber:EnergySize of the high-voltage batteryyes
battery#energy-contentNumber:EnergyMaximum energy content of the high-voltage batteryyes
battery#healthNumberBattery health as state of certified energy (SoCE)no
battery#energy-to-fullNumber:EnergyEnergy required to fully charge the batteryno
climate#comfort-stateStringState of the cabin preconditioningno
climate#progressNumber:DimensionlessProgress of the active preconditioningyes
climate#remaining-running-timeNumber:TimeRemaining running time of the preconditioningno
climate#target-temperatureNumber:TemperatureTarget cabin temperature of the preconditioningno
climate#rear-defrostSwitchWhether the rear window heating is activeyes
climate#mirror-heatingSwitchWhether the exterior mirror heating is activeyes
climate#air-purificationStringState of the cabin air purificationyes
climate#auxiliary-activityStringActivity of the auxiliary climate controlno
climate#auxiliary-remaining-timeNumber:TimeRemaining running time of the auxiliary climateno
climate#auxiliary-errorStringReason why the auxiliary climate did not runyes
navigation#gpsLocationCurrent location of the vehicleno
navigation#headingNumber:AngleCompass heading of the vehicleyes
navigation#altitudeNumber:LengthAltitude of the vehicle above sea levelyes
navigation#gps-fixStringQuality of the GPS positionyes
navigation#destination-distanceNumber:LengthDistance to the active navigation destinationno
navigation#arrival-timeStringExpected arrival time at the destination (hh:mm)no
trip#end-timeDateTimeTime when the last trip endedno
trip#end-mileageNumber:LengthTotal mileage at the end of the last tripyes
trip#end-socNumber:DimensionlessState of charge at the end of the last tripno
trip#recuperationNumberEnergy recovered during the last trip in kWh/100kmno
trip#comfort-energyNumber:EnergyEnergy consumed in COMFORT mode during the last tripyes
trip#electric-shareNumber:DimensionlessShare of the distance driven electricallyyes
trip#eco-pro-shareNumber:DimensionlessShare of the trip driven in ECO PRO modeyes
trip#eco-pro-plus-shareNumber:DimensionlessShare of the trip driven in ECO PRO+ modeyes
trip#acceleration-ratingNumberRating of the acceleration behaviour (0-5 stars)yes
trip#anticipation-ratingNumberRating of the anticipatory driving (0-5 stars)yes
tyres#pressure-front-leftNumber:PressureMeasured pressure of the front left tyreno
tyres#pressure-front-rightNumber:PressureMeasured pressure of the front right tyreno
tyres#pressure-rear-leftNumber:PressureMeasured pressure of the rear left tyreno
tyres#pressure-rear-rightNumber:PressureMeasured pressure of the rear right tyreno
tyres#target-front-leftNumber:PressureTarget pressure of the front left tyreyes
tyres#target-front-rightNumber:PressureTarget pressure of the front right tyreyes
tyres#target-rear-leftNumber:PressureTarget pressure of the rear left tyreyes
tyres#target-rear-rightNumber:PressureTarget pressure of the rear right tyreyes
tyres#temperature-front-leftNumber:TemperatureTemperature of the front left tyreyes
tyres#temperature-front-rightNumber:TemperatureTemperature of the front right tyreyes
tyres#temperature-rear-leftNumber:TemperatureTemperature of the rear left tyreyes
tyres#temperature-rear-rightNumber:TemperatureTemperature of the rear right tyreyes
security#alarmSwitchWhether the anti-theft alarm is going offno
security#arm-statusStringArming state of the anti-theft alarm systemno
security#activation-timeStringTime of the last alarm as reported by the vehicleyes
service#distanceNumber:LengthRemaining distance until the next serviceno
service#inspection-dateDateTimeDate of the next legal inspectionno
statistics#grid-energyNumber:EnergyTotal energy charged from the gridyes
statistics#fuel-consumedNumber:VolumeTotal fuel consumedyes
statistics#avg-consumptionNumberAverage electric consumption in kWh/100kmyes
statistics#avg-speedNumber:SpeedAverage speedyes
statistics#weekly-distanceNumber:LengthAverage distance driven per weekyes
statistics#weekly-distance-long-termNumber:LengthAverage distance per week over two monthsyes

The String channels show the values as reported by the vehicle; the door lock state is normalized, e.g. SELECTIVE-LOCKED becomes SELECTIVELOCKED. status#door-lock is ON for LOCKED and SECURED (locked with the alarm system armed), and OFF for UNLOCKED and SELECTIVELOCKED (all doors locked except the driver door). status#door-lock, status#trunk-locked and charge#flap-locked are ON when locked, so they can be combined in a group, e.g. Group:Switch:AND(ON,OFF). Windows and the sunroof are OPEN also when they are only partly open or tilted; the advanced -state channels show the reported state. Vehicles that do not report the state of charge header or the overall sunroof state, e.g. those of the Neue Klasse, update charge#soc and status#sunroof from the displayed state of charge and the sunroof state. Not every vehicle reports whether a charging cable is plugged in; until it does, charge#plugged follows the charging port status (CONNECTED or DISCONNECTED). Values the vehicle reports as unavailable (e.g. INVALID, -NA- or UNKNOWN), and values that cannot be interpreted, set the channel to UNDEF.

Dynamic Channels ​

BMW CarData provides several hundred data points, of which only the most common ones have a predefined channel. If dynamicChannels is enabled, the binding adds a channel for every other data point it receives through the stream. These data points need to be enabled in the customer portal. Note that data points that cannot be streamed and are not included in the binding will never become available as dynamic channels, even when your car could provide data.

Dynamic channels will also not get a state update at startup. They will only update from streamed data.

  • The channels are created in the channel group other.
  • The channel ID is the CarData identifier without the vehicle. prefix in lower-case-hyphen notation, e.g. vehicle.cabin.sunroof.tiltStatus becomes other#cabin-sunroof-tilt-status.
  • The item type is derived from the first received value: Switch for booleans, Number (with unit, e.g. Number:Length, if the data has one) for numbers and String otherwise.
  • The channel is created when the first value is received, so it does not exist before the vehicle reported the data.

For Things defined in .things files, dynamic channels are not stored and are created again when the data is received after a restart.

Troubleshooting ​

With the log level TRACE for org.openhab.binding.bmwcardata, the binding logs every request to BMW, every response and every stream message. These logs are redacted so they can be shared, e.g. in an issue:

  • A VIN is shortened to its first three and last four characters, e.g. WBA***1234.
  • Tokens, codes, the client ID, the customer ID (gcid) and the entityId are replaced by ***.
  • The values of the location coordinates are replaced by ***.

Other values, like the mileage or state of charge, are logged as received.

Full Example ​

bmwcardata.things Example ​

dsl
Bridge bmwcardata:account:myaccount "BMW CarData" [ clientId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ] {
    Thing vehicle i4 "BMW i4" [ vin="WBA00000000000000" ]
}

bmwcardata.items Example ​

dsl
Number:Length        i4_Mileage   "Mileage [%d %unit%]"           { channel="bmwcardata:vehicle:myaccount:i4:range#mileage" }
Number:Length        i4_Range     "Range [%d %unit%]"             { channel="bmwcardata:vehicle:myaccount:i4:range#electric" }
Number:Dimensionless i4_Soc       "State of Charge [%d %%]"       { channel="bmwcardata:vehicle:myaccount:i4:charge#soc" }
String               i4_Charging  "Charging [%s]"                 { channel="bmwcardata:vehicle:myaccount:i4:charge#status" }
Switch               i4_DoorLock  "Doors Locked [%s]"             { channel="bmwcardata:vehicle:myaccount:i4:status#door-lock" }
Location             i4_Location  "Location"                      { channel="bmwcardata:vehicle:myaccount:i4:navigation#gps" }
DateTime             i4_Updated   "Last Update [%1$tF %1$tR]"     { channel="bmwcardata:vehicle:myaccount:i4:status#last-update" }