BMW ConnectedDrive component

A fix for the HTTP 500 error is part of this PR.
cc @gregbert

Hi gerard33,

Thank you for the reply. I’m still a newbee with HA, can you point me in the right direction into applying this PR?

is this the way to go?
I’ve downloaded the files from bimmer_connected unzipped it and placed all the files in the bimmer_connected folder inside my custom_components directory in HA. Restarted HA.

I have 2 enities in the registry: lock.530d_lock & lock.535d_lock, both are unavailable.

When calling the Service “bmw_connected_drive.sound_horn” with the (correct car) vin provided I get:

Failed to call service bmw_connected_drive/sound_horn. The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).

Easiest is to wait for the HA release. The PR should be part of 0.102.

1 Like

ah oke, hero :slight_smile: thank you. I will be more patient :slight_smile:

Hi gerard33,

I’m a pretty good noob when it comes down to understanding code and stuff, so I’m still facing the issue the connected_drive integration is not working. The previous error is not being displayed anymore but I got a new one.

I upgraded my HA to version 0.102.1 (rebooted) and I still cannot get it to work.

here is my latest log:

Error doing job: Task exception was never retrieved
12:23 PM components/bmw_connected_drive/lock.py (ERROR) - message first occurred at 12:17 PM and shows up 6 times

Log Details (ERROR)
Fri Nov 22 2019 12:17:47 GMT+0100 (Central European Standard Time)
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/lock.py", line 64, in device_state_attributes
    "door_lock_state": vehicle_state.door_lock_state.value,
AttributeError: 'NoneType' object has no attribute 'value'

I get the same error in my log too. I think it might be because my vehicle is not able to supply lock status. It would be great if this could be removed if not available but maybe make a service to lock and unlock which my vehicle will still do

My ConnectedDrive app allows me to lock/unlock my vehicle, so I quess this should be working if the integration works. However I cannot get any information about my car, I also do not get any sensors or whatever in my HA.

Yes me too, but the BMW app doesn’t show the status of the lock so think the integration can’t read it and errors. If service calls for lock and unlock could be added instead of a lock entity that may work better in this instance.

I finally got this working. Running HA 0.102.2. It was a little bit difficult to get the options horn, lights and airco into my Lovelace UI but thanks to my friend hammerman I got this working. I now can sound the horn, flash the lights and activate the airco.

 - icon: mdi:car-connected
    title: BMW's
    cards:
        - type: entities
          title: BMW
          entities:
            - type: call-service
              icon: mdi:car-connected
              name: BMW
              action_name: Update State
              service: bmw_connected_drive.update_state
            - type: call-service
              icon: mdi:air-conditioner
              name: BMW
              action_name: Activate Airco
              service: bmw_connected_drive.activate_air_conditioning
              service_data: 
                vin: WBAMX7103xxxxxxxx

Now I still have another question. My ConnectedDrive app allows me to lock/unlock the doors, locate my vehicle and I know it is possible to get the current mileage too, but how to I get this working in HA?

@gerard33, is this implemented in the current integration? What do I have to do to get this working?
Is it even possible for my car? Can I assist in testing this or even troubleshoot it why this is not working?

The thing I still do not understand is why I have a lock entity via the bmw_connected_drive integration which is unavailable. Where is this coming from?

I still get this in the debug logging:

2019-11-26 22:12:52 DEBUG (SyncWorker_6) [homeassistant.components.bmw_connected_drive.device_tracker] Tracking is disabled for vehicle 535d
2019-11-26 22:12:52 DEBUG (SyncWorker_6) [homeassistant.components.bmw_connected_drive.device_tracker] Tracking is disabled for vehicle 530d
2019-11-26 22:12:52 DEBUG (SyncWorker_18) [homeassistant.components.bmw_connected_drive.lock] 530d: updating data for lock
2019-11-26 22:12:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/lock.py", line 64, in device_state_attributes
    "door_lock_state": vehicle_state.door_lock_state.value,
AttributeError: 'NoneType' object has no attribute 'value'
2019-11-26 22:12:52 DEBUG (SyncWorker_17) [homeassistant.components.bmw_connected_drive.lock] 535d: updating data for lock
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 275, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/lock.py", line 64, in device_state_attributes
    "door_lock_state": vehicle_state.door_lock_state.value,
AttributeError: 'NoneType' object has no attribute 'value'

@gerard33 It looks like the component now supports the reconnect if initial connection fails logic on the latest version of HA. I can’t remember the last time I had to re-reboot HA because of this component not initially connecting.

Thanks for getting this sorted, it’s made a huge difference.

It’s been some time since I had to reboot HA several times to get this integration to work and now it seems to just work normally after every reboot :slight_smile:

I am seeing this in the logs though, maybe someone can help me resolve it:

2019-12-13 08:47:14 ERROR (MainThread) [homeassistant.components.sensor] bmw_connected_drive: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/sensor.py", line 148, in update
    self._state = getattr(vehicle_state, self._attribute)
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/state.py", line 307, in __getattr__
    return self._attributes[item]
KeyError: 'maxFuel'

Any ideas?

Since yesterday I get following error

Sun Dec 15 2019 09:18:10 GMT+0100 (CET)

Authentication failed. Maybe your password is invalid?

The connect drive App and webpage is working. Only the ha Integration not anymore. Anyone face the same issue?

I have the same issue. Bmw push updates on a Saturday and I did get a new version in my car.

I’m guessing something has changed.

I’ll opened a issue on github

For the time being I will remove the component from my setup

Hello! Is there any way to do device_tracker? I get all the components of my bmw in HA minus the device_tracker. In the BMWconnected app it does mark the location, but in HA I can’t find the way. Can somebody help me?

You don’t have an entity show up called something like “device_tracker.i3_120” (that’s how mine shows up, no extra config required)

image

There is a Github issue made for this -> https://github.com/bimmerconnected/bimmer_connected/issues/145
So it’s on our list to see if we can make a fix for this.
cc @GitHubxtsnl

Thanks to Tim for providing the fix :+1:


The fix is made for the bimmer_connected library, so it’s actually not fixed in the HA integration by doing a reconnect, but his solution is working great.

It’s on our list via this Github issue -> https://github.com/bimmerconnected/bimmer_connected/issues/141
If you have any additional info to add regarding your car, please do that in that issue.

Ok so it is a work in progress and not fixed yet right?