BMW ConnectedDrive component

Commented out line 192:
…running bmwcdapi.py
Traceback (most recent call last):
File “./bmwcdapi.py”, line 467, in
main()
File “./bmwcdapi.py”, line 436, in main
c = ConnectedDrive()
File “./bmwcdapi.py”, line 116, in init
self.generate_credentials()
File “./bmwcdapi.py”, line 195, in generate_credentials
self.accesstoken = m.group(1)
AttributeError: ‘NoneType’ object has no attribute ‘group’

Commented out line 195 as well:
…running bmwcdapi.py
Traceback (most recent call last):
File “./bmwcdapi.py”, line 467, in
main()
File “./bmwcdapi.py”, line 436, in main
c = ConnectedDrive()
File “./bmwcdapi.py”, line 116, in init
self.generate_credentials()
File “./bmwcdapi.py”, line 195, in generate_credentials
self.accesstoken = m.group(1)
AttributeError: ‘NoneType’ object has no attribute ‘group’

Yeah line 195 is needed, so it won’t work without it.
Maybe someone from the US or Canada with some Python/API knowledge can give some support by looking how it’s done over here https://github.com/edent/BMW-i-Remote. I can’t test it as I don’t have an account for US.

try to install python on your mac

can you share your config here? may there is some issue inside, I guess it is no difference in getting the credentials regarding the token.

I think the i Remote app is different than the regular car one…

Also, Canada is still using the “BMW Remote” app, and NOT the new “BMW Connected” one.

In my case (in Germany) I can use both apps, bmw remote and bmw connected.

# ----=================================================----
# Enter the data below to be able to login
# Your BMW ConnectedDrive username
USERNAME = "[email protected]"             # "[email protected]"

# Your BMW ConnectedDrive password
PASSWORD = "password"             # "your_password"

# 17!! chars Vehicle Identification Number (VIN) of the car, can be found in the$
VIN = "17 digit VIN"           # "vin_code"

# This is the URL you use to login to BMW ConnectedDrive, e.g. www.bmw-connected$
URL = "https://b2vapi.bmwgroup.com"                  # "www.bmw-connecteddrive.n$

# This is the name of your car
CAR_NAME = "BMW X5"             # "BMW X1"

# The interval in minutes to check the BMW ConnectedDrive API, don't hammer it, $UPDATE_INTERVAL = "30"      # 30
# ----=================================================----

Yeah, in Canada only the Remote app is available for download. :frowning:

You have to remove https:// in the settings.
And can you also try b2vapi.bmwgroup.us?

Nope, that didn’t change anything.

Then making credentials is not working with your account.

Maybe this script won’t work for the BMW remote app then.

Hi Gerard,

Having a lot of trouble getting the script to run with /bin/python (in my Synology).
Using Python 3.5 starts something, but get error on a ‘*’:

sudo python3.5 ./bmwcdapi.py
File “./bmwcdapi.py”, line 97
self.update_interval = update_interval = * 60 # Change to seconds
^
SyntaxError: can’t use starred expression here

If I take out the ‘*’ this is what I get back:

/volume1/@appstore/py3k/usr/local/bin$ sudo python3.5 ./bmwcdapi.py
…running bmwcdapi.py
None: current credentials from BMW Connected Drive API still valid (token: VXbWuRcjq5BdFDUJJ1sTFiXVZylFRliU expires at: 2018-02-03 15:40:00)
Traceback (most recent call last):
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connection.py”, line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/util/connection.py”, line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/socket.py”, line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 601, in urlopen
chunked=chunked)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 346, in _make_request
self._validate_conn(conn)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 850, in _validate_conn
conn.connect()
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connection.py”, line 284, in connect
conn = self._new_conn()
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connection.py”, line 150, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f42634b4dd8>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py”, line 440, in send
timeout=timeout
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py”, line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/util/retry.py”, line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘none’, port=443): Max retries exceeded with url: /api/vehicle/dynamic/v1/WBS1H9109HV918157?offset=-60 (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7f42634b4dd8>: Failed to establish a new connection: [Errno -2] Name or service not known’,))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “./bmwcdapi.py”, line 467, in
main()
File “./bmwcdapi.py”, line 436, in main
c = ConnectedDrive()
File “./bmwcdapi.py”, line 119, in init
self.get_car_data()
File “./bmwcdapi.py”, line 236, in get_car_data
data_response = requests.get(self.bmw_url+’/dynamic/v1/’+self.bmw_vin+’?offset=-60’, headers=headers, allow_redirects=True)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/api.py”, line 72, in get
return request(‘get’, url, params=params, **kwargs)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/api.py”, line 58, in request
return session.request(method=method, url=url, **kwargs)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py”, line 508, in request
resp = self.send(prep, **send_kwargs)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py”, line 618, in send
r = adapter.send(request, **kwargs)
File “/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py”, line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘none’, port=443): Max retries exceeded with url: /api/vehicle/dynamic/v1/WBS1H9109HV918157?offset=-60 (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7f42634b4dd8>: Failed to establish a new connection: [Errno -2] Name or service not known’,))

//Robert

The original line 97 is
self.update_interval = update_interval * 60 # Change to seconds
So no second = which is in your lin 97 self.update_interval = update_interval = * 60 # Change to seconds.

Try to download the script again from Github and use that. You can send me a direct message when things are still not working, otherwise this topic will contain a lot of posts for a not working script which is just a temporary thing towards the real component :slight_smile:

Still working on the component.

Found a way that avoids the need of entering your VIN in the config and this has also the advantage that it supports all cars you have registered on BMW ConnectedDrive (for those with more than 1 BMW) :grinning:

Once that’s fully working I will add some sensors for electric and hybrid cars and after that I will make a first version of the component available over here :oncoming_automobile:

I have tried the new script without VIN - works :wink:

1 Like

Where can I have the uddated script ? I can find it. maybe I miss something while reading the thread. The GitHub link I found has no update for 1 month.

Check the bold text in my opening post.

many thanks :slight_smile:

Hey @gerard33,

just saw your comments on my pull request: https://github.com/home-assistant/home-assistant/pull/12277
My library for talking to the car is here: https://github.com/ChristianKuehnel/bimmer_connected

I was not aware of your work. I only checked the git repo, but not the community pages…
And yes joining forces definitely makes sense!
Where do you keep your code, so that we could compare the work?

br Christian

That’s great!
I have just sent you a message with more details.