Script to access the BMW ConnectedDrive portal via OH

Hi,
Quick answer. It will be a bit more complex. I just tried and got a 403 Forbidden answer on the request.post

Is there a doc somewhere about the connection or it’s reverse engineering ?

I also want to adapt script to add the service time on the interface.
condition_based_services 00001,OK,2022-01,25000;00100,OK,2024-01,50000;00003,OK,2023-01,;
means Oil service at 25000 or before 2022-01, car check at 50000 or before 2024-01 and break oil before 2023-01
(It will be good that the house announce me that I need to take appointment when I am at home and not in the car…)

@ifred:
Basically I’m just opening the connect-drive portal in Firefox and monitor the network-traffic i.e. when issuing commands with the build in network analysis (found under web-developer).

Authentication / getting the auth-token is another story of course.

I tried again but cannot find the solution :frowning:

I still get no updates with the script, too. Is it still working for someone else?

It’s working here without problems again since those hickups in late February.

Could you upload the script-file and post your region-item for me, please?

Not sure, if somethings wrong with mine.

thx to all. script also working fine for my X5 45e

Sorry for digging up such an old thread again.
The script worked very reliably for a long time now (Germany, i3). But since a few days I only get the following error message:

Remote end closed connection without response

Full Trace here: Pastebin
Region is set to “1”.
Does anyone else have the problem?

Cheers
Sven

@sdda:
Same problem here since around 10 days.

I’ll have a short look into it this weekend, but I can’t promise to fix it.
I’ll get a new car (ID.3 ) :slight_smile: shortly and after that I can’t support this script any longer.

From my point of view https://github.com/bimmerconnected/bimmer_connected is the most elaborated lib for connecting to the CD-portal right now.

So I think it would be best to make a small wrapper to use this lib in the future.

Peter

Peter,

thanks a lot in advance.
Will you take me on a test drive after the pandemic? I really like the design of the ID.3!

Cheers
Sven

Hi

i changed those lines in the script around line 90:

# old
#        headers = {
#                "Content-Type": "application/x-www-form-urlencoded",
#                "Content-Length": "124",
#                "Connection": "Keep-Alive",
#                "Host": self.serverUrl,
#                "Accept-Encoding": "gzip",
#                "Authorization": "Basic blF2NkNxdHhKdVhXUDc0eGYzQ0p3VUVQOjF6REh4NnVuNGNEanli"
#                                 "TEVOTjNreWZ1bVgya0VZaWdXUGNRcGR2RFJwSUJrN3JPSg==",
#                "Credentials": "nQv6CqtxJuXWP74xf3CJwUEP:1zDHx6un4cDjybLENN3kyfumX2kEYigWPcQpdvDRpIBk7rOJ",
#                "User-Agent": "okhttp/2.60",
#        }
# new

        headers = {
                "Content-Type": "application/x-www-form-urlencoded",
                "Content-Length": "124",
                "Connection": "Keep-Alive",
                "Host": "customer.bmwgroup.com",
                "Accept-Encoding": "gzip",
                "Authorization": "Basic ZDc2NmI1MzctYTY1NC00Y2JkLWEzZGMtMGNhNTY3MmQ3ZjhkOjE1"
                                 "ZjY5N2Y2LWE1ZDUtNGNhZC05OWQ5LTNhMTViYzdmMzk3Mw==",
                "Credentials": "nQv6CqtxJuXWP74xf3CJwUEP:1zDHx6un4cDjybLENN3kyfumX2kEYigWPcQpdvDRpIBk7rOJ",
                "User-Agent": "okhttp/3.12.2",
        }

now it works again.

Kr
linus

1 Like

I’m trying this out with a BMW X1 in Belgium.
I’m getting some info (updatetime, km-status, fuel status…).

2020-11-12 11:00:01.643 [vent.ItemStateChangedEvent] - Bmw_accessToken changed from NULL to h8nbhMhGhruDr84xi3QghiwmMRZuJKnb
2020-11-12 11:00:01.651 [vent.ItemStateChangedEvent] - Bmw_tokenExpires changed from NULL to 2020-11-12 13:00:00.644450
2020-11-12 11:00:03.173 [vent.ItemStateChangedEvent] - Bmw_mileage changed from 101618.0 to 103041
2020-11-12 11:00:03.184 [vent.ItemStateChangedEvent] - Bmw_beRemainingRangeFuel changed from 418.0 to 908.0
2020-11-12 11:00:03.190 [vent.ItemStateChangedEvent] - Bmw_lastUpdateReason changed from NULL to DOORSTATECHANGED
2020-11-12 11:00:03.198 [vent.ItemStateChangedEvent] - Bmw_unitOfLength changed from NULL to km
2020-11-12 11:00:03.205 [vent.ItemStateChangedEvent] - Bmw_doorLockState changed from NULL to LOCKED
2020-11-12 11:00:03.213 [vent.ItemStateChangedEvent] - Bmw_updateTimeConverted changed from NULL to 12.11.2020 10:45

But when I try to send a command (fe lights, doors…), I’m getting following error:

2020-11-12 11:10:55.426 [vent.ItemStateChangedEvent] - Bmw_UnlockDoors changed from OFF to ON
2020-11-12 11:10:55.434 [vent.ItemStateChangedEvent] - Bmw_UnlockDoors changed from ON to OFF

2020-11-12 11:11:03.728 [INFO ] [ipse.smarthome.model.script.bmwcdapi] - ...running bmwcdapi.py
executing service unlock
execStatusCode=70

This seems to be a communication error? Any idea where I must look?
The app from BMW is working for doors, lights…

btw, i just paid/activiated the remote services from BMW. Maybe it takes a while before this is synced. I’m just thinking out loud…

unfortunately this does not work at all , this includes the connected drive binding , no matter what logins you use, you’ll get a unauthorized or access token errors, at least in North america

My setup stopped updating some 6 days ago but I was running 2 year old version of that script.
I just updated to the latest version from the Github and all is good. it is working perfectly fine and I now see it is getting the car position as a new thing. Great.
Thank you.