bimmerconnected / bimmer_connected

🚘 Library to query the status of your BMW or Mini from the ConnectedDrive portal
Apache License 2.0
372 stars 81 forks source link

The BMW Connected Drive portal returned an error: UNKNOWN_ERROR (received status code 410 and expected 200). #325

Closed FilipDem closed 2 years ago

FilipDem commented 2 years ago

Describe the issue

Since today, I got an error "The BMW Connected Drive portal returned an error: UNKNOWN_ERROR (received status code 410 and expected 200).". The problem seems to be located in account.update_vehicle_states().

I have a small python script to test my integration... All worked until around noon... Then it started generating errors.

Below you can find the script I am using for testing and the (debug) log. I also included the urllib debug information...

CODE:

    print('\n********* AUTHENTICATION ************************************')
    account = ConnectedDriveAccount('fxxxxxxxxxxxe@xxxx.com', 'xxxxxxxxxxxx', get_region_from_name('rest_of_world'))

    print('\n********* UPDATE CAR STATUS *********************************')
    account.update_vehicle_states()

    print('Found {} vehicles: {}'.format(
        len(account.vehicles),
        ','.join([v.name for v in account.vehicles])))

    for vehicle in account.vehicles:
        print('VIN: {}'.format(vehicle.vin))
        print('Mileage: {}'.format(vehicle.state.vehicle_status.mileage))
        print('Vehicle properties:')
        print(json.dumps(vehicle.attributes, indent=4))
        print('Vehicle status:')
        print(json.dumps(vehicle.state.vehicle_status.attributes, indent=4))

DEBUG:

********* AUTHENTICATION ************************************
DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.account:Authenticating against GCDM with MyBMW flow.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): customer.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/authenticate HTTP/1.1" 200 432
DEBUG:bimmer_connected.account:got authorization challenge -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*
DEBUG:urllib3.connectionpool:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/authenticate HTTP/1.1" 302 0
DEBUG:bimmer_connected.account:got login code xxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:bimmer_connected.account:getting new oauth token
DEBUG:urllib3.connectionpool:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/token HTTP/1.1" 200 1991
DEBUG:bimmer_connected.account:got new token xxxxxxxxxxxxxxxxxxxxxxxx with expiration date 2021-11-09 21:53:55.089716
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles HTTP/1.1" 200 None

********* UPDATE CAR STATUS *********************************
DEBUG:bimmer_connected.state:requesting new data from connected drive
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): b2vapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://b2vapi.bmwgroup.com:443 "GET /webapi/v1/user/vehicles/WBAJF11030CD97578/status?deviceTime=2021-11-09T20%3A53%3A57&dlat=0.0&dlon=0.0 HTTP/1.1" 410 None
DEBUG:bimmer_connected.account:The BMW Connected Drive portal returned an error: UNKNOWN_ERROR (received status code 410 and expected 200).
DEBUG:bimmer_connected.account:<.........>
DEBUG:bimmer_connected.state:Service STATUS failed
DEBUG:bimmer_connected.state:{'STATUS': {}, 'LAST_TRIP': {}, 'ALL_TRIPS': {}, 'CHARGING_PROFILE': {}, 'DESTINATIONS': {}, 'RANGEMAP': {}, 'EFFICIENCY': {}, 'NAVIGATION': {}}
DEBUG:bimmer_connected.state:received new data from connected drive

Expected behavior

Normally the account.update_vehicle_states() should return the information as indicated in the code below. However the vehicle_status is empty with the following error description: DEBUG:bimmer_connected.vehicle_status:No data available for attribute <function VehicleStatus.mileage at 0x7f3d22c305e0>!

        print('VIN: {}'.format(vehicle.vin))
        print('Mileage: {}'.format(vehicle.state.vehicle_status.mileage))
        print('Vehicle properties:')
        print(json.dumps(vehicle.attributes, indent=4))
        print('Vehicle status:')
        print(json.dumps(vehicle.state.vehicle_status.attributes, indent=4))

Which Home Assistant version are you using?

(used outside HA)

What was the last working version of Home Assistant Core?

No response

What is your region?

Rest of world

ConnectedDrive website

Number of cars

Output of bimmer_connected fingerprint

No response

Anything in the logs that might be useful for us?

See above.

Additional information

No response

fabricioavil commented 2 years ago

+1, you aren't the only one. I was trying to understand what is happening as well, likely BMW changed something on their side.

I'm using HA to get the sensors, in HA many entities started reporting "unknown" state today as you mentioned, I tried to remove and re-add the integration, but many entities kept reporting "unknown" and others just weren't added again at all.

havrla commented 2 years ago

Heloo same problem, BMW server respond: ######################################## HTTP Status 410 - Gone type Status report messageGone descriptionThe requested resource is no longer available, and no forwarding address is known. Payara Micro #badassfish ########################################

The server behind this proxy is probably down. I'll wait 1 week, then I'll look for where to get the data. The URL for obtaining the SOC battery still works, it also contains the coordinates. BASE_URLL = 'b2vapi.bmwgroup.com' url = 'https://' + BASE_URLL + '/api/vehicle/navigation/v1/' + vin respond: {'auxPowerEcoPro': 1.0, 'auxPowerEcoProPlus': 1.0, 'auxPowerRegular': 1.0, 'latitude': 48.141177, 'longitude': 15.796112, 'pendingUpdate': False, 'soc': 100.0, 'socmax': 38.76, 'vehicleTracking': True}

Havrla

FilipDem commented 2 years ago

I also got general vehicle information back, but it is not complete. Eg. we don't get the vehicle status anymore (vehicle_status) and this includes eg the mileage. F

lolouk44 commented 2 years ago

wonder if related but when using the official My BMW App, my last refreshed status is yesterday at 5.30PM (UK)

danfulton72 commented 2 years ago

My app (android) shows last updated 10/11/2021 14:47 (that'a 10 November) so that's not an issue for me.

On Wed, 10 Nov 2021 at 15:17, lolouk44 @.***> wrote:

wonder if related but when using the official My BMW App, my last refreshed status is yesterday at 5.30PM (UK)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bimmerconnected/bimmer_connected/issues/325#issuecomment-965372601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKHZQZAPGPMDSXIO6U5BK4LULKEHFANCNFSM5HWGFBCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

FilipDem commented 2 years ago

Same for me, my app gives the status update of today. @lolouk44 : probably there were no changes in the status since yesterday... If the status has not changed, I think the date is not updated...

obhammer commented 2 years ago

Heloo same problem, BMW server respond: ######################################## HTTP Status 410 - Gone type Status report messageGone descriptionThe requested resource is no longer available, and no forwarding address is known. Payara Micro #badassfish ########################################

The server behind this proxy is probably down. I'll wait 1 week, then I'll look for where to get the data. The URL for obtaining the SOC battery still works, it also contains the coordinates. BASE_URLL = 'b2vapi.bmwgroup.com' url = 'https://' + BASE_URLL + '/api/vehicle/navigation/v1/' + vin respond: {'auxPowerEcoPro': 1.0, 'auxPowerEcoProPlus': 1.0, 'auxPowerRegular': 1.0, 'latitude': 48.141177, 'longitude': 15.796112, 'pendingUpdate': False, 'soc': 100.0, 'socmax': 38.76, 'vehicleTracking': True}

Havrla

O’hey - I can see you get answer for the ‘socmax’ value on your query 😳 That’s the MOST important value that we can get for an EV, and should ABSOLUTELY be a own entity in HA. Socmax is the exact number for ‘’currently useable battery capacity’’ and is a direct indication for how much energy stored at 100% as well as monitoring of eventual loss in battery capacity over time. Would be VERY nice to have this as an entity in HA…

rikroe commented 2 years ago

Hi all, still not sure if the BMW APIs are just broken or actually shut off.

Please jump over to https://github.com/bimmerconnected/bimmer_connected/discussions/327 to help us with some data contributions on what the My BMW API will return for your vehicle, so we can start migrating.

@obhammer I understand that this is quite important for EVs, however this is part of a legacy-legacy API. I hope socMax is also available in the My BMW API so we have everything in one place. Nevertheless our focus is first on getting the errors out of the picture ;)

platyguy commented 2 years ago

I'm having the same issue. No Vehicle Status output.

andig commented 2 years ago

Note that https://github.com/TA2k/ioBroker.bmw doesn't have a open login issue. Can anyone confirm that it still works?

andig commented 2 years ago

Please jump over to #327 to help us with some data contributions on what the My BMW API will return for your vehicle, so we can start migrating.

@rikroe afaiu this issue is about token auth during login and not related to the actual API calls. Are you aware of a different login mechanism as part of My BMW?

TA2k commented 2 years ago

iobroker is using the v2 API from the current MyBMW. I think rkroe already adopted this.

andig commented 2 years ago

Regarding login, iobroker uses auth code exchange:

        client_id: "31c357a0-7a1d-4590-aa99-33b97244d048",
        response_type: "code",
        scope: "openid profile email offline_access smacc vehicle_data perseus dlm svds cesim vsapi remote_services fupo authenticate_user",
        redirect_uri: "com.bmw.connected://oauth",
        state: "cEG9eLAIi6Nv-aaCAniziE_B6FPoobva3qr5gukilYw",
        nonce: "login_nonce",
        username: this.config.username,
        password: this.config.password,
        grant_type: "authorization_code",

while I've sofar (and imho bimmer) used direct login:

    "username":      []string{v.user},
    "password":      []string{v.password},
    "client_id":     []string{"31c357a0-7a1d-4590-aa99-33b97244d048"},
    "redirect_uri":  []string{"com.bmw.connected://oauth"},
    "response_type": []string{"token"},
    "scope":         []string{"authenticate_user vehicle_data remote_services"},
    "nonce":         []string{"login_nonce"},

both against the same endpoint (https://customer.bmwgroup.com/gcdm/oauth/authenticate).

I don't think this difference has anything todo with v2 api changes?

rikroe commented 2 years ago

Yes, we have adopted the My BMW login flow already.

It is the actual vehicle status we got from the "old" Connected Drive API that is now broken. Our problem is now that the new My BMW API returns a different data structure at different endpoints.

That's why we are asking for fingerprints to get an overwiew what features are available. Then we have to adopt our code because basically every attribute was hard codes into the library.

andig commented 2 years ago

Ahh, sorry for the confusion. Then I got side-tracked and my error is a different topic.

havrla commented 2 years ago

When you mentioned LOGIN

I was surprised that BMW provided the car data to third parties. Watch: Video mobille app: https://cloud.itnaklic.cz/itnaklic/index.php/s/5GRwteGft2KmGmo

An application for ordering mobile car charging while you are in the office. The charger operator open/closes the car and charges it. I'm sorry if I'm behind and you've already registered this news about getting car data. I don't know exactly how it works in the background. Havrla

rsteininger commented 2 years ago

Hi all, I had reported the status issue as a separate error.

What I wanted to point out is, that the finger print function still returns the (sorry, for me) relevant status information in: vehicles_v2_0.txt

So, the information seems to be still accessible, but maybe not via the currently used mechanism ...

lolouk44 commented 2 years ago

@rsteininger I don't think anyone is disputing this. The issue is the API structure has changed. So yes you as a human can spot the data being present, but the current code needs to be updated to pick up the data from the right place, hence the request to provide data in https://github.com/bimmerconnected/bimmer_connected/discussions/327 to help identify what is returned for each car type and where it is in the "stream" 😉

rsteininger commented 2 years ago

@lolouk44 cool! didn't know! will upload my fingerprint info as well! THANKS

rikroe commented 2 years ago

I was surprised that BMW provided the car data to third parties.

Yes, BMW does provide this Car Data API, however there is a price tag on it.

rsteininger commented 2 years ago

question to the development team: I understand that you want to try and "restore" the previous functionally of the vehicle status.

However, for me, I could actually live with with the output from "vehicles_v2_0".

One comment, one question:

Thanks!

rikroe commented 2 years ago

A quick update: Thanks for all your contributions, I was able to start working on it. But please be patient for a while, I'll keep you posted (also with beta versions to try it out).

@rsteininger the "cli" output was an idea however we didn't get to realise it yet. It's still planned!

obhammer commented 2 years ago

8AD32494-9198-4740-93BF-589E1A2C49ED

This is probably the reason for API changes - new version and features for the ‘’My BMW’’ app…

Swantu commented 2 years ago

I can confirm that the BMW api returns a 410 for all "interesting" values. For me, that effects EVCC (0.65), IO-Broker (with 2.0.0 BMW Adapter) but not the APP - App is working after update.

rikroe commented 2 years ago

Good news! I just created beta releases for both the python library (bimmer_connected==0.8.0b2) and our custom component (20211113.1) that should enable My BMW APIs.

⚠️ It is still beta and all tests fail, but you should get some data back into Home Assistant.

Please check the release notes of both carefully and let us know if anything doesn't work. When it is smoothed out a little bit we will create a PR to get it included in HA proper.

andig commented 2 years ago

I've tried this with a 2020 i3. Vehicle is found, but then:

Traceback (most recent call last):
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 272, in <module>
    main()
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 268, in main
    args.func(args)
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 104, in get_status
    print('Mileage: {}'.format(vehicle.state.vehicle_status.mileage))
AttributeError: 'NoneType' object has no attribute 'vehicle_status'
blenni commented 2 years ago

Thank you.

I get the following issue when I try to get the vehicle status:

Found 1 vehicles: i3s 120
VIN: xxx
Traceback (most recent call last):
  File "/home/pi/.local/bin/bimmerconnected", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/bimmer_connected/cli.py", line 268, in main
    args.func(args)
  File "/home/pi/.local/lib/python3.7/site-packages/bimmer_connected/cli.py", line 104, in get_status
    print('Mileage: {}'.format(vehicle.state.vehicle_status.mileage))
AttributeError: 'NoneType' object has no attribute 'vehicle_status'
FilipDem commented 2 years ago

Same errors for me... vehicle: 518d

rikroe commented 2 years ago

Thanks for the report! The cli issue should be fixed with bimmer_connected==0.8.0b3/custom component 20211114.1. You also now have a pure JSON output.

andig commented 2 years ago

i don't think its fixed:

Traceback (most recent call last):
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 281, in <module>
    main()
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 277, in main
    args.func(args)
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 115, in get_status
    print('Mileage: {}'.format(vehicle.state.vehicle_status.mileage))
AttributeError: 'NoneType' object has no attribute 'vehicle_status'

at

commit a4db0f6837cc7696578596e3643e55c5a6090d39 (HEAD -> mybmw, tag: 0.8.0b3, origin/mybmw)
Author: rikroe <rikroe@users.noreply.github.com>
Date:   Sun Nov 14 13:32:38 2021 +0100

    Fix cli output and add JSON-only flag
rikroe commented 2 years ago

i don't think its fixed:

Dang, I looking to hard on --json output and missed it... New version 0.8.0b4 and new custom component are out!

andig commented 2 years ago

Working now. I'd like to port this to https://github.com/evcc-io/evcc but don't really understand which api call actually does the heavy lifting? Is it /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1636900326.277933&tireGuardMode=ENABLED?

andig commented 2 years ago

Ah, I see. It is https://cocoapi.bmwgroup.com/eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1636901442.283914&tireGuardMode=ENABLED. The cli output is confusing as it prints this as object {} while of course- in the absence of a vin- this must be a slice [].

havrla commented 2 years ago

heloo version: Successfully installed bimmer-connected-0.8.0.0b4

BMW I3 charging 44%, cable connected BMW I3 Rex full 100%, cable connected

CLI fingerprint charging-sessions_0.txt charging-sessions_1.txt charging-statistics_0.txt charging-statistics_1.txt vehicles_v2_bmw_0.txt vehicles_v2_mini_0.txt

CLI status error

Found 2 vehicles: i3,i3 (+ REX) VIN: WBY1Z21020V607314 Mileage: (69080, 'km') Vehicle data: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/bimmer_connected/cli.py", line 281, in main() File "/usr/local/lib/python3.6/site-packages/bimmer_connected/cli.py", line 277, in main args.func(args) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/cli.py", line 117, in get_status print(to_json(vehicle, indent=4)) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/utils.py", line 37, in to_json return json.dumps(obj, default=serialize, args, kwargs) File "/usr/lib64/python3.6/json/init.py", line 238, in dumps kw).encode(obj) File "/usr/lib64/python3.6/json/encoder.py", line 201, in encode chunks = list(chunks) File "/usr/lib64/python3.6/json/encoder.py", line 438, in _iterencode yield from _iterencode(o, _current_indent_level) File "/usr/lib64/python3.6/json/encoder.py", line 430, in _iterencode yield from _iterencode_dict(o, _current_indent_level) File "/usr/lib64/python3.6/json/encoder.py", line 404, in _iterencode_dict yield from chunks File "/usr/lib64/python3.6/json/encoder.py", line 437, in _iterencode o = _default(o) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/utils.py", line 36, in serialize return getattr(obj, 'to_json', getattr(obj, 'dict') if hasattr(obj, 'dict') else str(obj)) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/utils.py", line 46, in to_json return serialize_for_json(self) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/utils.py", line 21, in serialize_for_json {a: getattr(obj, a) for a in get_class_property_names(obj) if a not in excluded + ["to_json"]} File "/usr/local/lib/python3.6/site-packages/bimmer_connected/utils.py", line 21, in {a: getattr(obj, a) for a in get_class_property_names(obj) if a not in excluded + ["to_json"]} File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 300, in are_all_cbs_ok for cbs in self.condition_based_services: File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 100, in _func_wrapper raise ex File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 95, in _func_wrapper return func(self, args, **kwargs) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 295, in condition_based_services return [ConditionBasedServiceReport(s) for s in self.properties['serviceRequired']] File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 295, in return [ConditionBasedServiceReport(s) for s in self.properties['serviceRequired']] File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 440, in init self.due_date = VehicleStatus._parse_datetime(cbs_data.get('dateTime')) File "/usr/local/lib/python3.6/site-packages/bimmer_connected/vehicle_status.py", line 336, in _parse_datetime raise ValueError("unable to parse '{}' using {}.".format(date_str, date_formats)) ValueError: unable to parse '2023-10-01T00:00:00.000Z' using ['%Y-%m-%dT%H:%M:%S.%f%z', '%Y-%m-%dT%H:%M:%S%z']. [root@CL-ITNK-BMW ~]#

havrla commented 2 years ago

rikroe: Hi, please send me your contact, I'll give you access to BMW for faster testing , havrla@lhotkanet.cz

rikroe commented 2 years ago

Thanks for the report, it should be fixed with bimmer_connected==0.8.0b5/custom component 20211114.3.

It was an issue with date parsing in Python 3.6 that I didn't check (and currently all our test still break so no testing against multiple python versions yet).

havrla commented 2 years ago

version b5 with BMW i3 DC charger 50kW charging-sessions_0.txt charging-sessions_1.txt charging-statistics_0.txt charging-statistics_1.txt vehicles_v2_bmw_0.txt vehicles_v2_mini_0.txt

FilipDem commented 2 years ago

Hi @rikroe! First of all a big thanks! Just an suggestion... I am using this library to integrate with Domoticz (not HA). I want to get regularly updates, but perhaps it is not useful to start the complete authentication phase as long as the token is valid. And I see that this can only be done by using the function _get_vehicles(). Seen the underscore it is normally an internal function however I would suggest to make a public one so that it can be called directly.

Btw: the current internal one cannot be used as it appends always the new same vehicles to the list...

Thanks, Filip

FilipDem commented 2 years ago

I saw a bug in the list of Windows... In your code you define WINDOWS = ['windowDriverFront', 'windowPassengerFront', 'windowDriverRear', 'windowPassengerRear', 'rearWindow', 'sunroof']... While in my fingerprint (I uploaded it earlier also), I got "moonroof" instead of "sunroof". See extract of the fingerprint below. Why not reading the list of doors & windows from the API instead of coding them? If you prefer I am creating another bug report instead of continuing on this one, let me know...

      "doorsAndWindows": {
        "doors": {
          "driverFront": "CLOSED",
          "driverRear": "CLOSED",
          "passengerFront": "CLOSED",
          "passengerRear": "CLOSED"
        },
        "hood": "CLOSED",
        "moonroof": "CLOSED",
        "trunk": "CLOSED",
        "windows": {
          "driverFront": "CLOSED",
          "driverRear": "CLOSED",
          "passengerFront": "CLOSED",
          "passengerRear": "CLOSED"
        }
      },
rikroe commented 2 years ago

Thanks for that! The WINDOWS is removed already as I do not need it anymore. But moonroof is a very good catch, thank you!

andig commented 2 years ago

The image command is broken:

DEBUG:urllib3.connectionpool:https://cocoapi.bmwgroup.com:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1636986839.295627&tireGuardMode=ENABLED HTTP/1.1" 200 2
Traceback (most recent call last):
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 285, in <module>
    main()
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 281, in main
    args.func(args)
  File "/Users/andig/htdocs/bimmer_connected/bimmer_connected/cli.py", line 197, in image
    image_data = vehicle.get_vehicle_image(400, 400, VehicleViewDirection.FRONT)
TypeError: get_vehicle_image() takes 2 positional arguments but 4 were given
romachandr commented 2 years ago

Authorization stopped working for me today. I tried it on several versions of the library ('0.8.0.0b7', '0.8.0.0b8'). Is it related to this issue or is it a different problem?

CODE:

print('\n********* AUTHENTICATION ************************************')
account = ConnectedDriveAccount(username=LOGIN, password=PASSWORD, region=get_region_from_name('rest_of_world'))

DEBUG:

********* AUTHENTICATION ************************************
DEBUG:Getting vehicle list
DEBUG:Authenticating against GCDM with MyBMW flow.
DEBUG:Starting new HTTPS connection (1): customer.bmwgroup.com:443
DEBUG:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/authenticate HTTP/1.1" 200 432
DEBUG:got authorization challenge xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/authenticate HTTP/1.1" 400 304
ERROR:Authentication failed (invalid_request): The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed
Traceback (most recent call last):
  File "C:\Anaconda3\envs\testenv\lib\site-packages\bimmer_connected\account.py", line 174, in _get_oauth_token
    raise ex
  File "C:\Anaconda3\envs\testenv\lib\site-packages\bimmer_connected\account.py", line 128, in _get_oauth_token
    response.raise_for_status()
  File "C:\Anaconda3\envs\testenv\lib\site-packages\requests\models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://customer.bmwgroup.com/gcdm/oauth/authenticate
python-BaseException
rikroe commented 2 years ago

Should work again with 0.8.0.0b9!

blenni commented 2 years ago

0.8.0.0b9 fixes the login error, but does not find my vehicle:

DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.account:getting new oauth token
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): customer.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://customer.bmwgroup.com:443 "POST /gcdm/oauth/authenticate HTTP/1.1" 302 0
DEBUG:bimmer_connected.account:got new token g80RJOaMeU6NqkZGbCvcV9Gj91s with expiration date 2021-11-17 23:11:00.325289
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:bimmer_connected.account:Request to: https://cocoapi.bmwgroup.com/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): cocoapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://cocoapi.bmwgroup.com:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1637179861.331386&tireGuardMode=ENABLED HTTP/1.1" 200 7065
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:bimmer_connected.account:Request to: https://cocoapi.bmwgroup.com/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): cocoapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://cocoapi.bmwgroup.com:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1637179864.016556&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://cocoapi.bmwgroup.com/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): cocoapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://cocoapi.bmwgroup.com:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1637179865.208548&tireGuardMode=ENABLED HTTP/1.1" 200 7065
DEBUG:bimmer_connected.account:Old token is still valid. Not getting a new one.
DEBUG:bimmer_connected.account:Request to: https://cocoapi.bmwgroup.com/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): cocoapi.bmwgroup.com:443
DEBUG:urllib3.connectionpool:https://cocoapi.bmwgroup.com:443 "GET /eadrax-vcs/v1/vehicles?apptimezone=60.0&appDateTime=1637179866.86309&tireGuardMode=ENABLED HTTP/1.1" 200 2
Found 0 vehicles:

MyBMW-App and EVCC is still working.

FilipDem commented 2 years ago

Hi, I suppose there is a problem with the def get_vehicle(self, vin: str) -> ConnectedDriveVehicle:. See the small test script and result below. If I get my car by using the get_vehicle, I got a None back (not found). However when I loop over all the found vehicles, it prints the VIN of my car. Same after an update_vehicle_states(). My car is no longer in the list then because get_vehicle gives also None.... Am I doing sth wrong? Or is there a problem with the lookup?

    print('\n********* AUTHENTICATION ************************************')
    account = ConnectedDriveAccount('xxx, 'xxx', get_region_from_name('rest_of_world'))
    print('Found {} vehicles: {}'.format(
        len(account.vehicles),
        ','.join([v.name for v in account.vehicles])))

    print('\n********* TRY TO FIND MY CARE BASED ON VIN ******************')
    v = account.get_vehicle('XXX')
    if v:
        print('Mileage: {}'.format(v.status.mileage[0]))
    else:
        print('VIN XXX not found!')

    print('\n********* UPDATE CAR STATUS *********************************')
    for vehicle in account.vehicles:
        print('VIN: {}'.format(vehicle.vin))
        print('Brand: {}'.format(vehicle.brand))
        print('Mileage: {}'.format(vehicle.status.mileage))

Gives the following result:

********* AUTHENTICATION ************************************
Found 1 vehicles: 518d

********* TRY TO FIND MY CARE BASED ON VIN ******************
Mileage: 21515

********* UPDATE CAR STATUS *********************************
VIN: XXX
Brand: bmw
Mileage: (21515, 'km')

********* ENTERING LOOP FOR STATUS UPDATES ******************
VIN XXX not found!
rikroe commented 2 years ago

@FilipDem you are right, I just saw it myself while implementing the BMW app login flow. It should be fixed with 0.8.0b10.

blenni commented 2 years ago

It is working again - thanks for fixing problems so quick 👍

Pirol62 commented 2 years ago

Just updated and everything is working as usual. Thanks to @rikroe and all other contributors. Great work. It was obviously a tricky one ;-)

obhammer commented 2 years ago

@rikroe - don’t know if you are aware of this, but the sensor.xxx.charging.time.remaining seem to be miscalculated. This log is taken from a charging session that lasted approx 1 hour, came out like this: E1AFBBC2-22EF-433E-A6FB-E93D4B3B2DAF

github-actions[bot] commented 2 years ago

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.