BMW ConnectedDrive component

With HA 64.0, I get two sensors (mileage, fuel) […]
After entering the Connect App (Android) and locating the car once, I now also get the device_tracker.

After a day of observation, I can add the following:

  • The device_tracker state does not update itself, only if I restart HA
  • The two sensors (mileage, remaining fuel) do not update at all, not even after a restart

Anyone got the device_tracker configured to show up on the map?

@irqnet works fine here. Got a 225xe hybrid.

Works here too (idrive touch)

Which config entry do I have to add?

I only have the ones stated in the component page except the “name:” part;

bmw_connected_drive:
  mycar:
    username: USERNAME_BMW_CONNECTED_DRIVE
    password: PASSWORD_BMW_CONNECTED_DRIVE
    country: COUNTRY_BMW_CONNECTED_DRIVE

Ah i see, devices that are currently ‘at home’ are not shown on the map :smiley: my fault!

Great work on this, big thanks. Really nice be able to monitor and control my i3 in HomeKit. Makes it much easier to turn on the pre-heating, lock the car etc etc.

Is it planned to add a feature to read the charging state and battery level of the i3? If so, please let me know if there’s anything I can do to help out with that.

1 Like

As @irqnet already stated that will indeed work, but I noticed that the car will be in the locked state then and not the secure state. So probably the alarm will not be turned on. Please take that in consideration, but on the other hand if HA detects your car is still open and it locks it (after some checks) that’s always better than an unlocked car :grin:

We have noticed that some cars have less information available on the API and also don’t auto refresh the data. Check this post from @danielperna84 for some more details.

That’s a really nice picture of your Homekit screen :grinning:
Makes me realize I didn’t even implemented that for my car yet.

Yes it certainly is. @Svellem just provided us with the API data of his i3, so more features for electric cars will be made available.

Do i need to log in first?

can’t seem to pull any data on a 420 made in beginning of 2015. Using the library I can horn flash and whatever, no problem. The custom components don’t add any switches/locks because the code tries to read the gps data from the json which is undefined/null and throws an exception.

Good hint, i will try that. I didn’t know that there are different ways to lock the car (push the button on the remote once or twice) and I didn’t know that my car got an alarm as well :smiley: since I left my dog in the car some weeks ago and the alarm starts :smiley:

So i guess there must be another status of the lock.bmw_lock entity?

last_update: 2018-02-27T17:02:01
car: X1 sDrive18d
door_lock_state: LOCKED

If the car is locked with the remote (pressing once) the door_lock_state is SECURED (probably only when the car has an alarm).

I am still seenng loads of errors when using the custom_components. Seems to complain that it can’t find any data (I am in the UK):

Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 223, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/config/custom_components/switch/bmw_connected_drive.py", line 69, in device_state_attributes
    'last_update': vehicle_state.timestamp,
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 46, in _func_wrapper
    raise ValueError('No data available!')
ValueError: No data available!
2018-02-28 08:04:40 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 44, in _func_wrapper
    return func(self, *args, **kwargs)
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 91, in timestamp
    unix_time = int(self._attributes['updateTime_converted_timestamp'])
KeyError: 'updateTime_converted_timestamp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 223, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/config/custom_components/switch/bmw_connected_drive.py", line 69, in device_state_attributes
    'last_update': vehicle_state.timestamp,
  File "/config/deps/lib/python3.6/site-packages/bimmer_connected/state.py", line 46, in _func_wrapper
    raise ValueError('No data available!')
ValueError: No data available!


Can confirm, location tracking is working and my car is actually shown in the defined zone where I parked it a couple of minutes ago. Also the lock state matches correctly when the alarm is on.

May we can change the icon of the switch in dependency of the lock state?

1 Like

I have configured the Component according to the documentation (but removed name). However this is what I am seeing:

Log Details (ERROR)
Wed Feb 28 2018 13:02:26 GMT+0100 (W. Europe Standard Time)
Error during setup of component bmw_connected_drive
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 148, in _async_setup_component
component.setup, hass, processed_config)
File “/usr/lib/python3.6/asyncio/futures.py”, line 332, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 250, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/bmw_connected_drive.py”, line 52, in setup
bimmer = BMWConnectedDriveAccount(username, password, country, name)
File “/usr/lib/python3.6/site-packages/homeassistant/components/bmw_connected_drive.py”, line 83, in init
self.account = ConnectedDriveAccount(username, password, country)
File “/usr/lib/python3.6/site-packages/bimmer_connected/account.py”, line 52, in init
self._get_vehicles()
File “/usr/lib/python3.6/site-packages/bimmer_connected/account.py”, line 158, in _get_vehicles
self._get_oauth_token()
File “/usr/lib/python3.6/site-packages/bimmer_connected/account.py”, line 83, in _get_oauth_token
self._oauth_token = url_with_token[‘access_token’][0]
KeyError: ‘access_token’

This is my configuration:
bmw_connected_drive:
mycar:
username: [email protected]
password: mySecretPass
country: Sweden

What shall I do to troubleshoot?

@silfa718 Try both before and after login, I guess.

@ChristianKuehnel I think the API is located at https://b2vapi.bmwgroup.us but the problem is my account can’t seem to get a OAuth access token from customer.bmwgroup.com or wherever the OAuth server is. Maybe there is a different server for Canada and the USA that we need to be looking for?

2018-02-27 23:46:57 ERROR (MainThread) [homeassistant.setup] 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'

I’m having a problem with configuration.yaml. Fails!!

Testing configuration at /config
ERROR:homeassistant.config:Invalid config for [bmw_connected_drive]: [name] is an invalid option for [bmw_connected_drive]. Check: bmw_connected_drive->bmw_connected_drive->mycar->name. (See /config/configuration.yaml, line 66). Please check the docs at https://home-assistant.io/components/bmw_connected_drive/
ERROR:homeassistant.setup:Setup failed for bmw_connected_drive: Invalid config.
Failed config
bmw_connected_drive:
mycar: [source /config/configuration.yaml:67]
country: USA
name: XXXX <------- This is the problem. Not liasted on the USA Site
password: my password
username: my username

Where do I find the “name:” It is not listed anywhere on https://connecteddrive.bmwusa.com

It has alll my other data…

Thanks

You don’t need the “name” part just leave it out.

the documentation is broken, a patch is on the way…
https://github.com/home-assistant/home-assistant.github.io/pull/4769