BMW ConnectedDrive component

The component released in version 98 is looking good. I can see the sunroof state even when it’s tilted open. Great!

I see there are some new icons on the overview, those are nice, too.

Re: maxfuel sensor. It still doesn’t have a unit attached. On my i3, this shows 8. Just 8. Not eight gills or 8 cups or 8 cubic centimeters. Just 8. My guess is this is 8 liters, because my fuel remaining sensor shows 2 (Imperial, not US*) gallons – and I think the tank is full – and with one significant figure, there’s 4 liters/gallon. This sensor should have a unit attached, and converted to the user’s units when required.

*This is another separate, unrelated, but significant bug in Home Assistant itself: US units of measure are not supported, only Imperial and SI. And particularly in volume units, these measures are meaningfully different.

Im also running the 98.1 but I still get lots of errors in the log when I try to add my F11:

remote services are booked and the app on my iPhone works as intended.

2019-08-30 22:15:40 ERROR (MainThread) [homeassistant.setup] Error during setup of component bmw_connected_drive
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 172, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  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/__init__.py", line 49, in setup
    accounts.append(setup_account(account_config, hass, name))
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 77, in setup_account
    cd_account = BMWConnectedDriveAccount(username, password, region, name, read_only)
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 127, in __init__
    self.account = ConnectedDriveAccount(username, password, region)
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 55, in __init__
    self._get_vehicles()
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 192, in _get_vehicles
    logfilename='vehicles')
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 136, in send_request
    raise IOError(msg)
OSError: The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).

bmw_connected_drive:
  name:
    username: !secret bmw_cd_user
    password: !secret bmw_cd_pw
    region: rest_of_world
    read_only: true

anyone an idea what im doing wrong?

This is caused by the Connected Drive portal not being able to process the request correctly. Just restart HA a few times until it works. Check this post as well → BMW ConnectedDrive component - #464 by WhimsySpoon

Great to hear the sunroof is working correctly now :grinning:
Can you make an issue on bimmer_connected Github for the maxfuel sensor including a screenshot of the entity with it’s attributes? Looks like that sensor is not setup with a unit yet.

Did it.

Also, what do you think of unit “%” for HV battery (charging_level_hv)? It seems to be possible in general. E.g., the component for Epson Ecotank printers shows the remaining ink levels as %.

Thanks. Yes the percentage for charging_level_hv can be added.
Have some more questions on other sensors added to the GH issue.

Can I request that we NOT add % sign? I use the battery level in some notification automations inside NodeRED and I need it to be a number only for it to work. Perhaps a separate sensor that includes % sign could be created so we can choose which one we need for our HA?

This will be no issue as the state of the entity will stay the same. I will just add an unit of measurement attribute to the entity. HA uses that to show it in the frontend, but the state will not have the % so you can still use Nodered :smile:

Is it possible to get the turn on remote climate functionality or is that available in the apis?
3D remote view would also be nice :wink:

The remote climate service is already supported, the howto is described in the docs -> https://www.home-assistant.io/components/bmw_connected_drive/

My bad, I actually forgot I already set that up :sweat_smile:
Is it possible to actually get confirmation back that did execute successfully? Would be nice to set up a notification with simplePush to say hey this is done (because it fails sometimes even in the BMW app)

@gerard33 Would it be possible to include some retry login in the start up of the component?

I know this isn’t an issue with the component, rather BMW’s unreliable web service, but its painful if I need to restart HA because I’ve made a change to my config (totally unrelated to this component), only to find that I need to restart it another couple of times just to get a good connection to their web service.

I was thinking of that myself as well and checked it on Discord and that’s indeed possible.
Will do some testing and make a PR for this.

3 Likes

That’s great news, thanks! Happy to assist with any testing.

Hmm saw this in the sensor list for my 330e: 330e chargingInductivePositioning
I wonder if it has support for wireless charging… :thinking:

Getting the error. Any help?

Worked before on my 0.93 version. Made a fresh install on OS and HA 100.03. Now i got this error.

HTTPSConnectionPool(host='b2vapi.bmwgroup.com', port=443): Max retries exceeded with url: /gcdm/oauth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])")))
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 485, in wrap_socket
    cnx.do_handshake()
  File "/srv/homeassistant/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1915, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/srv/homeassistant/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error
    _raise_current_error()
  File "/srv/homeassistant/lib/python3.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/connection.py", line 394, in connect
    ssl_context=context,
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 370, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 491, in wrap_socket
    raise ssl.SSLError("bad handshake: %r" % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/srv/homeassistant/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='b2vapi.bmwgroup.com', port=443): Max retries exceeded with url: /gcdm/oauth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/bimmer_connected/account.py", line 89, in _get_oauth_token
    expected_response=200, post=True)
  File "/srv/homeassistant/lib/python3.7/site-packages/bimmer_connected/account.py", line 126, in send_request
    response = requests.post(url, headers=headers, data=data, allow_redirects=allow_redirects, params=params)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='b2vapi.bmwgroup.com', port=443): Max retries exceeded with url: /gcdm/oauth/token (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])")))

You probably also installed Debian Buster at the same time?
In that case you can check here for the solution.

1 Like

Indeed. Thanks for the fast help. I’ll check the workound tomorrow. Seems to be the config of openssl

Setting up new
Error from home-assistant: The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).

I would greatly appreciate any help!

EDIT: I see people say to restart. i’ve done that several times. I am also not paying anything for the connected+ . seems i may need to have that. but not sure why i would get these errors.

Here is my config:

bmw_connected_drive:
  name:
    username: !secret email
    password: !secret passwordbmw
    region: rest_of_world

I am in switzerland. my account is on https://www.bmw-connecteddrive.ch/
I am running home-assistant 0.101.2

here is relevant log:

2019-11-06 19:16:12 ERROR (SyncWorker_14) [homeassistant.components.bmw_connected_drive] Could not connect to the BMW Connected Drive portal. The vehicle state could not be updated.
2019-11-06 19:16:12 ERROR (SyncWorker_14) [homeassistant.components.bmw_connected_drive] The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 142, in update
    self.account.update_vehicle_states()
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 215, in update_vehicle_states
    car.update_state()
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/vehicle.py", line 72, in update_state
    self.state.update_data()
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/state.py", line 130, in update_data
    params=params)
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 136, in send_request
    raise IOError(msg)
OSError: The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).

running HA 0.101.3
newbee here on HA.
I have the same errors when running the BMW ConnectedDrive integration:
bmw_connected_drive.activate_air_conditioning / { “vin”:“WBANXXXXXX1234567” }
The app on my iPhone works like a charm, also when connecting to www.bmw-connecteddrive.nl I have no issues.

2019-11-08 15:26:34 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1884274320] The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1263, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  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/__init__.py", line 94, in execute_service
    function_call()
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/remote_services.py", line 120, in trigger_remote_air_conditioning
    self._trigger_remote_service(_Services.REMOTE_AIR_CONDITIONING, post=True)
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/remote_services.py", line 133, in _trigger_remote_service
    return self._account.send_request(url, post=post, data=data)
  File "/usr/local/lib/python3.7/site-packages/bimmer_connected/account.py", line 136, in send_request
    raise IOError(msg)
OSError: The BMW Connected Drive portal returned an error: SERVER_ERROR (received status code 500 and expected 200).