I just realize I really need a test drive in your M2 before I can add this component to Home Assistant
That’s a really nice car!
Can you send me some screenshots on how the Volvo stuff (sensors etc) are shown in Home Assistant? I can use that as inspiration for how to show the BMW ConnectedDrive data.
Traceback (most recent call last):
File "/Users/me/PycharmProjects/untitled/bmwcdapi.py", line 375, in <module>
main()
File "/Users/me/PycharmProjects/untitled/bmwcdapi.py", line 342, in main
c = ConnectedDrive()
File "/Users/me/PycharmProjects/untitled/bmwcdapi.py", line 84, in __init__
self.generate_credentials()
File "/Users/me/PycharmProjects/untitled/bmwcdapi.py", line 125, in generate_credentials
tokenType = (m.group(2))
AttributeError: 'NoneType' object has no attribute 'group'
Process finished with exit code 1
Well, I got further. It looks like I have a connecteddrive.bmwusa.com account where I can see my car, its status, and everything and separately I have a customer.bmwgroup.com where I have no cars listed. It looks like this code lists cars from the second account and then would get the details from the first. Because it can’t find my car, I now get:
UnboundLocalError: local variable 'map_car_data' referenced before assignment
<Response [404]>
I’ll try and call BMW tomorrow to see if they can merge the accounts or minimally ensure my car is on the second account.
…running bmwcdapi.py
400
Traceback (most recent call last):
File “bmwcdapi.py”, line 345, in
main()
File “bmwcdapi.py”, line 333, in main
execStatusCode = c.get_car_data()
File “bmwcdapi.py”, line 163, in get_car_data
return map_car_data
UnboundLocalError: local variable ‘map_car_data’ referenced before assignment
It looks like the variables map_car_data and map_car_navigation where not defined before return in the specified functions.
I’ve tested that by adding two lines in the script.
I indeed noticed that the url for USA differs from other countries, where it is www.bmw-connecteddrive.[countrycode].
I will have a look at the customer.bmwgroup.com url to see if my car is registered there.
Ah i will check that. Using the german URL with .de ending but using the short VIN Code like in the BMW App. Have to grab my papers out of the car to check the full number.
I have checked this with @irnqnet offline and it’s showing data (partly) when using bmwcdapi.py -p.
Will do some extra checks what is causing the 404 in the script and release an updated version.
In the meanwhile of I have changed the script on Github so it contains some more information on what data to enter in the fields including some examples, where you have to replace the None parts with your data as shown in the examples in those lines.
# ----=================================================----
# Enter the data below to be able to login
# Your BMW ConnectedDrive username
USERNAME = None # "[email protected]"
# Your BMW ConnectedDrive password
PASSWORD = None # "your_password"
# 17!! chars Vehicle Identification Number (VIN) of the car, can be found in the app or on BMW ConnectedDrive online
VIN = None # "vin_code"
# This is the URL you use to login to BMW ConnectedDrive, e.g. www.bmw-connecteddrive.nl or www.bmw-connecteddrive.de
URL = None # "www.bmw-connecteddrive.nl"
# ----=================================================----
the values for username, password, VIN and URL have to be included in " " or ’ ’
For registering my car in the german version of the BMW connected app I have to use the last 7 digits of my VIN. To use this script it is necessary to use the whole VIN (in my case 17 digits)
The only useful information I get is the position. Which is nice. But for me the mileage and fuel-stats would be way more interesting. :-/
For reference (since we can’t change what data the API delivers), the exact type of my XY:
Got the same car, at least 2017 model. But the information you will get as result of the script depends on the connected drive subscription you have. Do you have the remote services subscribed in your account?
I think it may be the BMW Connected+ that’s causing the trouble. Unfortunately, when I try to order the service it says my car is not compatible. Maybe mine has some older hardware installed.