You may be aware that BMW broke the ConnectedDrive HA integration. Instead, you’re supposed to use the BMW CarData API. This API is free to use with your own car. It doesn’t allow control commands, but I don’t need that anyway. In this topic, I want to discuss making use of this data in Home Assistant (or any MQTT consumer)!
Don’t want to tinker? Check out the BimmerData Streamline custom HA integration. It may be suitable for your needs!
BMW CarData availability is limited to a few countries.
BMW CarData does not allow controlling EV charging.
BMW CarData has two APIs, one is a REST API and one is an MQTT server. I found the REST API to be fairly useless, it offers little data of interest. The MQTT server, on the other hand, basically throws all the information you could ever want at you.
Authentication with the MQTT server is handled using an OAuth2 REST API. And then, you already have an MQTT server inside HA already anyway. Luckily, someone went and created a forwarding agent for BMW CarData specifically:
I’ve been running it for quite some time now and it works flawlessly. Thank you, dj0abr!
When setting this up yourself, make sure to follow the guides:
- First, from the BimmerData Streamline custom integration, use the great instructions (quoted below) to simply enable all data subscriptions
- When using Docker, follow the instructions exactly, to facilitate the initial login
Connect the bridge to your MQTT broker (usually Mosquitto managed by Home Assistant). Further bridge configuration depends on whether custom processing is desired or not. Check the following posts!
Enabling all data, quoted from BimmerData Streamline README:
BMW Portal Setup (DON’T SKIP, DO THIS FIRST)
The CarData web portal isn’t available everywhere (e.g., it’s disabled in Finland). You can still enable streaming by logging in by using supported region. It doesn’t matter which language you select - all the generated Id and configuration is shared between all of them.
BMW
- https://www.bmw.co.uk/en-gb/mybmw/vehicle-overview (in English)
- https://www.bmw.de/de-de/mybmw/vehicle-overview (in German)
Mini
- Loading... (in English)
- Loading... (in German)
- Select the vehicle you want to stream.
- Choose BMW CarData or Mini CarData.
- Generate a client ID as described here: CarData Customer Portal
- Subscribe the client to both scopes:
cardata:api:read(Request access to CarData API) andcardata:streaming:read(CarData Stream) and click authorize.
Note, BMW portal seems to have some problems with scope selection. If you see an error on the top of the page, reload it, select one scope and wait for +30 seconds, then select the another one and wait agin.- Scroll to the Data Selection section (
Datenauswahl ändern) and load all descriptors (keep clicking “Load more”).- Check every descriptor you want to stream. To automate this, open the browser console and run:
(() => { const labels = document.querySelectorAll('.css-k008qs label.chakra-checkbox'); let changed = 0; labels.forEach(label => { const input = label.querySelector('input.chakra-checkbox__input[type="checkbox"]'); if (!input || input.disabled || input.checked) return; label.click(); if (!input.checked) { const ctrl = label.querySelector('.chakra-checkbox__control'); if (ctrl) ctrl.click(); } if (!input.checked) { input.checked = true; ['click', 'input', 'change'].forEach(type => input.dispatchEvent(new Event(type, { bubbles: true })) ); } if (input.checked) changed++; }); console.log(`Checked ${changed} of ${labels.length} checkboxes.`); })();[…]
- Save the selection.
- Repeat for all the cars you want to support
[…]
Now you have the data you want on your MQTT broker. Continue reading to find out how to work with it!
It’s probably also possible to have the MQTT bridge run as a Home Assistant App (formerly Add-on). Sounds like a fun mini project!