Closed rikroe closed 2 years ago
Hi, I am a bimmer and HA user from China. I have figured out the login mechanism in MyBMW. However, I am not a programmer and know nothing about python. You can find the login mechanism in the Siri Shortcuts I wrote for BMW:
All Shortcuts download link MyBMW login Shortcuts
Hope this helps.
Hello,BMW ConnectedDrive China How long is it expected to be released
@muxiachuixue thanks! Unfortunately I am not able to translate what you have written. @zhaozengxiao no idea :( If the login issue is understood, will be very quick.
\"command_url_prefix\":\"https://myprofile.bmw.com.cn/eadrax-vrccs/v2/presentation/remote-commands/\", \"climate_on_url_postfix\":\"/climate-now?action=START\", \"climate_off_url_postfix\":\"/climate-now?action=STOP\", \"lock_url_postfix\":\"/door-lock\", \"unlock_url_postfix\":\"/door-unlock\", \"light_url_postfix\":\"/light-flash\", \"horn_url_postfix\":\"/horn-blow\", \"event_url_postfix\":\"eventStatus?eventId=\", \"status_url\":\"https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles?apptimezone=480&appDateTime=\", \"status_vin_url_prefix\":\"https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles/\", \"status_vin_url_postfix\":\"/state?apptimezone=480&appDateTime=\", \"token_url\":\"https://myprofile.bmw.com.cn/eadrax-coas/v1/oauth/token\", \"login_url\":\"https://myprofile.bmw.com.cn/eadrax-coas/v1/login/pwd\", \"publickey_url\":\"https://myprofile.bmw.com.cn/eadrax-coas/v1/cop/publickey\", \"jsencrypt_url\":\"https://gitee.com/ichuixue/bmw_shortcuts/raw/master/BMW_JSEncrypt.js\", \"check_in_url\":\"https://myprofile.bmw.com.cn/cis/eadrax-community/private-api/v1/mine/check-in\", \"joy_list_url\":\"https://myprofile.bmw.com.cn/cis/eadrax-membership/api/v2/joy-list\", \"article_list_url\":\"https://myprofile.bmw.com.cn/cis/eadrax-ocommunity/public-api/v1/article-list\", \"share_article_url\":\"https://myprofile.bmw.com.cn/cis/eadrax-oarticle/open/article/api/v2/share-article\", \"joy_info_url\":\"https://myprofile.bmw.com.cn/cis/eadrax-membership/api/v1/joy-info\",
Excuse me, is this useful?
@muxiachuixue thanks! Unfortunately I am not able to translate what you have written. @zhaozengxiao no idea :( If the login issue is understood, will be very quick.
I will make a clear one for you.
@rikroe Now the Shortcuts for MyBMW in China will be more easier to read and understand: MyBMW login Lock MyBMW Status of MyBMW
Anything I can help, please let me know.
When I click on one of the shortcuts, it says "not found". Do I need an iPhone for this? Also on MacOS I get a "not found".
Just saw your link to BMW_JSEncrypt.js
. This is the only thing missing on is how to encrypt the password for login/pwd
.
From what you posted I understand the password is send using RSA public key encryption.
However I am not able to (re-)create valid passwort hashes that I have seen. Do you only need to encrypt the password? Or More?
EDIT: Nevermind, I figured it out! Will try to implement it before it gets merged into Home Assistant.
EDIT2: got a first implementation working. Will create some tests and then give it to you for testing.
@rikroe I'm just a porter, All his credit @muxiachuixue ,I really want to take the test, thank you
When I click on one of the shortcuts, it says "not found". Do I need an iPhone for this? Also on MacOS I get a "not found".
Just saw your link to
BMW_JSEncrypt.js
. This is the only thing missing on is how to encrypt the password forlogin/pwd
. From what you posted I understand the password is send using RSA public key encryption.However I am not able to (re-)create valid passwort hashes that I have seen. Do you only need to encrypt the password? Or More?
EDIT: Nevermind, I figured it out! Will try to implement it before it gets merged into Home Assistant.
EDIT2: got a first implementation working. Will create some tests and then give it to you for testing.
The IOS Shortcuts need the App "Scriptable" to run the JavaScript codes. If you have not installed the App, a "not found" error will come out. If you need a Chinese BMW account for testing, please let me and @zhaozengxiao know. Thanks again for the efforts.
@rikroe After installing the bimmer-connected-0.8.1.dev1 version on my raspberry pi 4B, I executed the following command:
bimmerconnected status 8615201231234 password1234 china
And got the error outputs:
`DEBUG:bimmer_connected.account:Getting vehicle list DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-coas/v1/cop/publickey HTTP/1.1" 200 356 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "POST /eadrax-coas/v1/login/pwd HTTP/1.1" 200 731 DEBUG:bimmer_connected.account:got new token eyJhbGciOiJIUzI1NiIsInR5xxxxxxxxImV4cCI6MTYzNzc1OTY0NywiaWF0Ijxxxxxxxr5V62o5yw9urSL2IvMG9IzyF7s with expiration date 2021-11-24 13:14:07 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637727547.929913&tireGuardMode=ENABLED HTTP/1.1" 200 7517 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637727549.340775&tireGuardMode=ENABLED HTTP/1.1" 200 2 DEBUG:bimmer_connected.account:Getting vehicle list DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637727550.503834&tireGuardMode=ENABLED HTTP/1.1" 200 7517 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637727551.604555&tireGuardMode=ENABLED HTTP/1.1" 200 2 Found 1 vehicles: 325i VIN: LBV5F340ABCD01234 Mileage: (13547, 'km') Vehicle data: DEBUG:bimmer_connected.vehicle_status:No data available for attribute <function VehicleStatus.charging_level_hv at 0xb56f18e8>! ValueError: '已上锁' is not a valid LockState
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/bin/bimmerconnected", line 10, in
@rikroe Thank you for your efforts!I want to know how to use the new version in Home Assistant?Thank you!!!
@muxiachuixue ouch, seems the API is returning chinese instead of english...
Could you please try one thing for me and and edit /home/pi/.local/lib/python3.7/site-packages/bimmer_connected/account.py
L272-L276 so it looks like this (added accept-language
):
headers = {
"accept": "application/json",
"x-user-agent": X_USER_AGENT.format(brand.value),
"Authorization": "Bearer {}".format(self._oauth_token),
"accept-language": "en",
}
Let me know if that works for you!
@zhaozengxiao it just got merged into Home Assistant, so it should be included in the next major version.
@muxiachuixue ouch, seems the API is returning chinese instead of english...
Could you please try one thing for me and and edit
/home/pi/.local/lib/python3.7/site-packages/bimmer_connected/account.py
L272-L276 so it looks like this (addedaccept-language
):headers = { "accept": "application/json", "x-user-agent": X_USER_AGENT.format(brand.value), "Authorization": "Bearer {}".format(self._oauth_token), "accept-language": "en", }
Let me know if that works for you!
@zhaozengxiao it just got merged into Home Assistant, so it should be included in the next major version.
After adding the "accept-language" line as you told, I can get the correct outputs of the car status json data. However, before the json data, you can see the following lines. Is it OK?
DEBUG:bimmer_connected.account:Getting vehicle list DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-coas/v1/cop/publickey HTTP/1.1" 200 356 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "POST /eadrax-coas/v1/login/pwd HTTP/1.1" 200 731 DEBUG:bimmer_connected.account:got new token eyJhbGciOiJIUzI1NiIsIxxxxxBJDE2Mzc4MTAyMjUwNTMiLCJuYmYiOjE2Mxxxxxx3ODEwMjI1fQ._F33fIjXbh5Sn0srxxxxxpcQWTqdVBY with expiration date 2021-11-25 04:12:05 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637781425.01832&tireGuardMode=ENABLED HTTP/1.1" 200 7410 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637781426.85447&tireGuardMode=ENABLED HTTP/1.1" 200 2 DEBUG:bimmer_connected.account:Getting vehicle list DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637781429.366527&tireGuardMode=ENABLED HTTP/1.1" 200 7410 DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Request to: https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): myprofile.bmw.com.cn:443 DEBUG:urllib3.connectionpool:https://myprofile.bmw.com.cn:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1637781430.841364&tireGuardMode=ENABLED HTTP/1.1" 200 2 Found 1 vehicles: 325i VIN: LBV5xxxxABCD12345 Mileage: (13569, 'km') Vehicle data: DEBUG:bimmer_connected.vehicle_status:No data available for attribute <function VehicleStatus.charging_level_hv at 0xb56c1858>!
{
"attributes": {
"vin": "LBV5xxxxABCD12345",
"vehicleType": "connected",
"licensePlate": "XXXXXX",
"cdActiveStatus": "ACTIVATED",
...
}
It is quite strange that, the car status json data from the IOS shortcut shows less information than the data from your bimmerconnected program in linux. For example, the "last_update_reason" does not show in the shortcut result. The POST request is like this in IOS shortcut:
Header: { "accept":"application/json" "Authorization":"Bearer $access_token", "x-user-agent":"ios(14.8);bmw;1.4.0(7743)" "accept-language":"en" }
Same in postman as IOS shortcut. What did I miss?
Edit: I got it. The information I missed is defined in your codes. As for the "inMotion" attribute, when I start the engine for several minutes (not move), the "inMotion" value is still false. Haven't try to check it when the car is moving.
Thanks, this is looking good then!
@rikroe Hello, I am a beginner in python. After I pull the package, what command should I use to test? ? ?
'bimmerconnected fingerprint <8618860629999> <123456789>
Enter this in the console?
It is not a implemented in the official package yet, I will do that after work and let you know.
Also I'll give you the command you need to use.
It is not a implemented in the official package yet, I will do that after work and let you know.
Also I'll give you the command you need to use.
Thanks @rikroe
It is not a implemented in the official package yet, I will do that after work and let you know.
Also I'll give you the command you need to use.
bimmerconnected status 8615201231234 password1234 china
It is not a implemented in the official package yet, I will do that after work and let you know. Also I'll give you the command you need to use.
bimmerconnected status 8615201231234 password1234 china
Thanks @muxiachuixue
Just released 0.8.3.0b1.
It can be installed via pip3 install --upgrade bimmer_connected==0.8.3.0b1
and should continue the fix for chinese responses in the My BMW API.
I have just updated the custom component as well to try it out.
Just released 0.8.3.0b1.
It can be installed via
pip3 install --upgrade bimmer_connected==0.8.3.0b1
and should continue the fix for chinese responses in the My BMW API.I have just updated the custom component as well to try it out.
Nice, I have tried the HA custom component 0.8.3.0b4. It works well. Thanks again.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Describe the issue
Starting with
0.8.0
, support for regionchina
had to be dropped.We are currently unable to figure out the login mechanism used. If you want to jump in and help us fixing it, we can provide full network traffic.
Workaround: Use
bimmer_connected<0.8.0
or the Home Assistant custom component BMW ConnectedDrive China (to be released soon).Expected behavior
Login to
china
possible, reuse of existing vehicle endpoints.Which Home Assistant version are you using?
none
What was the last working version of Home Assistant Core?
No response
What is your region?
China
ConnectedDrive website
Number of cars
Output of bimmer_connected fingerprint
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response