BMW ConnectedDrive component

I’m using the custom component, name value does not work.

For device_tracker you have to edit the known_devices.yaml and enable tracking for the bmw device tracker, if your new devices are not automaticaly are tracked.

Ah ha, of course! I can now see device_tracker, mileage and remaining fuel.

Would love to see lock status and perhaps send an action to lock the car if it isn’t already when going to bed.

I had to take out the “name” line to get my configuration to validate, but I am still getting an error when the front page loads.

It shows " KeyError: ‘access_token’ "…I’ve checked my user name and password and its correct.

I do have two cars in my BMW Connect account, not sure if that is causing my issue.

The name field probably ended up unintentionally in the config.yaml example. Will check that with @ChristianKuehnel so it can be changed in the instruction.

That should work (although it’s the first time we can test this :slight_smile:) . Did you use the right name of the country in the configuration file exactly as it is shown on BMW ConnectedDrive?

I used “USA” for the Country.

Here is some more info on the BMW ConnectedDrive component.

Home Assistant 0.64
In HA 0.64 release the BMW ConnectedDrive component is available with:

  • Device tracker
  • Mileage (sensor)
  • Remaining fuel (sensor)
  • Remaining range fuel (sensor)

We are working on adding more items to the component, you can check here for more information.
These extra items will be made available in the next releases of HA.

While working on that there is a custom component available over here which contains (parts) of these new items.

Custom component
The custom component currently contains the following extra items (beside the ones mentioned above):

  • Door lock state (binary sensor)
  • Doors (binary sensor)
  • Windows (binary sensor)
  • Lock (lock)
  • Horn (switch)
  • Lights (switch)
  • Climate (switch)
1 Like

Could be that ConnectedDrive is not yet working correctly for USA and Canada.
Can you check this post?

And can you follow these instructions to see if the data is available for you?

That seems like the same issue as mentioned here. We’ll take care of it :thinking:

The links in that post don’t work for me.

Try using https://crm.bmw.ca/en-CA/ConnectedDrive/Account
It seems to look at lot more similar to the login pages that you get in other countries, without the other bmw.ca stuff around the login form…
(I just found it by snooping around in the HTML source code, so honestly it’s just a wild guess)

I’m currently updating my Home Assistant instance to try it out.

Wont let me login.

It seems to work normally for me, at least in a web browser

Edit: Sorry, I realized that you are from USA, not Canada. Maybe the US has a similar url to https://crm.bmw.ca/en-CA/ConnectedDrive/Account ?

I’m getting this in Canada:
Error during setup of component bmw_connected_drive Traceback (most recent call last): File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 148, in _async_setup_component component.setup, hass, processed_config) File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/components/bmw_connected_drive.py", line 52, in setup bimmer = BMWConnectedDriveAccount(username, password, country, name) File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/components/bmw_connected_drive.py", line 83, in __init__ self.account = ConnectedDriveAccount(username, password, country) File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/bimmer_connected/account.py", line 52, in __init__ self._get_vehicles() File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/bimmer_connected/account.py", line 158, in _get_vehicles self._get_oauth_token() File "/srv/homeassistant/homeassistant/lib/python3.5/site-packages/bimmer_connected/account.py", line 83, in _get_oauth_token self._oauth_token = url_with_token['access_token'][0] KeyError: 'access_token'

Is there a way I can manually specify a url? I want to try https://crm.bmw.ca/en-CA/ConnectedDrive/Account
It looks like it’s failing at a step that uses OAuth. Does the OAuth step contact a country specific server or is it the same across all countries? I have a feeling that some countries don’t use the central OAuth system, like Canada and US

The issue is: I can’t debug the other countries, as I cannot create an account for these countries. My guess is that the url for the login page is not the one I’m getting from https://www.bmw-connecteddrive.com/country-select/country-selection.html

Can you debug the login process with the developer tools in Firefox/Chrome.
What I’m looking for is the {server} part for these urls:

REMOTE_SERVICE_URL = '{server}/api/vehicle/remoteservices/v1/{vin}/{service}'
VEHICLE_STATE_URL = '{server}/api/vehicle/dynamic/v1/{vin}'
VEHICLE_SPECS_URL = '{server}/api/vehicle/specs/v1/{vin}'
LIST_VEHICLES_URL = '{server}/api/me/vehicles/v2'

I hope that only the {server} is different and that the rest of the API is the same…

1 Like

and the name: field is a bug in the documentation. leave that one away.

The fix for the documentation is on the way:
https://github.com/home-assistant/home-assistant.github.io/pull/4769

1 Like

I was capturing packets from the BMW Remote App, and it seems to be contacting https://b2vapi.bmwgroup.us

Is there a way we can manually try this url?

I tried https://b2vapi.bmwgroup.us/api/vehicle/specs/v1/{vin} :

{"error":"invalid_token","error_description":"The access token provided is expired, revoked, malformed, or invalid for other reasons."}

I couldn’t find anything useful in the sources of the login page :frowning:

I’m willing to help out, let me know what you need me to do.

Which page do you need me to get that debug info for the {server}?

@silfa718 I think he wants the login page, but I couldn’t find any references to “API” or whatever in the Canadian login page…

It would help knowing where to look.

Go to the website where you usually login to ConnectedDrive, then do a “Inspect element”, then use Ctrl+F to find anything that might mention “API”. Try looking around in the sources tab in the inspection window as well.