bimmer_connected
bimmer_connected copied to clipboard
Fingerprint command fails while fetching charging session
Describe the issue
Running bimmerconnected fingerprint <email> <password> rest_of_world
fails when fetching charging sessions:
httpx.HTTPStatusError: Client error '404 Resource Not Found' for url 'https://cocoapi.bmwgroup.com/eadrax-chs/v1/charging-sessions?vin=<VIN>&maxResults=40&include_date_picker=true'
Expected behavior
The bimmmerconnected fingerprint
command succeeds since these same credentials work with a MyBMW app.
Which Home Assistant version are you using?
n/a
What was the last working version of Home Assistant Core?
n/a
What is your region?
Rest of world
MyBMW website
- [X] I can still successfully login to the BMW MyBMW website and the car status is available there.
- [X] I have MyBMW enabled for my vehicle.
Number of cars
- [ ] I have 2 or more cars linked to the MyBMW account.
- [ ] I have a Mini vehicle linked to my account.
Output of bimmer_connected fingerprint
No response
Anything in the logs that might be useful for us?
DEBUG:asyncio:Using selector: KqueueSelector
DEBUG:bimmer_connected.account:Getting vehicle list
DEBUG:bimmer_connected.api.authentication:Authenticating with MyBMW flow for North America & Rest of World.
DEBUG:httpx._client:HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-ucs/v1/presentation/oauth/config "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: POST https://customer.bmwgroup.com/gcdm/oauth/authenticate "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: POST https://customer.bmwgroup.com/gcdm/oauth/authenticate "HTTP/1.1 302 Found"
DEBUG:httpx._client:HTTP Request: POST https://customer.bmwgroup.com/gcdm/oauth/token "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v1/vehicles?apptimezone=120.0&appDateTime=1655650524567&tireGuardMode=ENABLED "HTTP/1.1 200 OK"
DEBUG:httpx._client:HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-vcs/v1/vehicles?apptimezone=120.0&appDateTime=1655650524567&tireGuardMode=ENABLED "HTTP/1.1 200 OK"
Getting 'charging-sessions' for <VIN>
DEBUG:httpx._client:HTTP Request: POST https://cocoapi.bmwgroup.com/eadrax-chs/v1/charging-sessions?vin=<VIN>&maxResults=40&include_date_picker=true "HTTP/1.1 404 Resource Not Found"
Traceback (most recent call last):
File "/Users/mislav/Library/Python/3.8/bin/bimmerconnected", line 8, in <module>
sys.exit(main())
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/bimmer_connected/cli.py", line 263, in main
loop.run_until_complete(args.func(args))
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/bimmer_connected/cli.py", line 142, in fingerprint
await client.post(
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1842, in post
return await self.request(
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1527, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1614, in send
response = await self._send_handling_auth(
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1642, in _send_handling_auth
response = await self._send_handling_redirects(
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1700, in _send_handling_redirects
raise exc
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
await hook(response)
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/bimmer_connected/api/client.py", line 64, in raise_for_status_event_handler
response.raise_for_status()
File "/Users/mislav/Library/Python/3.8/lib/python/site-packages/httpx/_models.py", line 736, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Resource Not Found' for url 'https://cocoapi.bmwgroup.com/eadrax-chs/v1/charging-sessions?vin=<VIN>&maxResults=40&include_date_picker=true'
Additional information
I have also tried the code in https://github.com/bimmerconnected/bimmer_connected/pull/458, but that fails with a different error:
DEBUG:httpx._client:HTTP Request: GET https://cocoapi.bmwgroup.com/eadrax-crccs/v1/vehicles/<VIN>?fields=charging-profile&has_charging_settings_capabilities=true "HTTP/1.1 500 Internal Server Error"
Thanks for the report! Can't test it myself, don't have an EV.
As you already used the code from #458, you try adding the following header: "24-hour-format": "true"
?
@rikroe I've added the header but it doesn't seem to have any effect on the HTTP 500 error.
diff --git a/bimmer_connected/cli.py b/bimmer_connected/cli.py
index 4a5d3c3..813396e 100644
--- a/bimmer_connected/cli.py
+++ b/bimmer_connected/cli.py
@@ -149,7 +149,10 @@ async def fingerprint(args) -> None:
await client.get(
f"/eadrax-crccs/v1/vehicles/{vehicle['vin']}",
params={"fields": "charging-profile", "has_charging_settings_capabilities": True},
- headers={"bmw-current-date": datetime.utcnow().isoformat()},
+ headers={
+ "bmw-current-date": datetime.utcnow().isoformat(),
+ "24-hour-format": "true",
+ },
)
except httpx.HTTPStatusError:
pass
:/ Then I'm very much at a loss why it doesn't work. Just to double check: you are able to set charging profiles in the MyBMW app, right?
@rikroe I'm not sure what "charging profiles" in the app are. I'm using the app in Dutch language. The only charging settings that the app offers me is to change from "direct" (i.e. uninterrupted) mode of charging to only allowing charging between certain start time and end time.
However, if this is a feature that is not available to my car or region, I would have expected that the server would respond with something other than a HTTP 500. I reported this because I thought maybe the library sends some wrong parameters and triggers the 500 somehow. Maybe the library could treat server errors as non-fatal and just print them as warnings to stderr, but the figerprinting could allow to continue?
I've tried using the Home Assistant integration that uses this library, but it didn't allow me to log in (it would say that an error occurred). That's why I went to use the library directly to see if I can help report a bug better. I am able to run the status command but not the fingerprint command. I do not actually depend on the result of the fingerprint command for anything. Not sure which command is used for Home Assistant integration during login.
Thank you for maintaining this library!
I this case, you can ignore these charging endpoints for now. They are not used by the library at all and just part of the fingerprint to gather some more data.
Maybe your error has something to do with https://github.com/home-assistant/core/issues/73370 or https://github.com/home-assistant/core/issues/73713?
@rikroe I'll dig deeper for the cause of the HA failure. Thanks for the pointers!
You may close this issue at your convenience. 🙇
While we don't need it right now, I would like to understand why some EVs are able to provide the eadrax-crccs/v1/vehicles/<VIN>?fields=charging-profile&has_charging_settings_capabilities=true
endpoint and some don't.
Could you please provide the vehicles and state files from your fingerprint? Maybe there is a flag somewhere...
@rikroe Sure, which files do you need, and should I share it in the open here?
BTW I was able to add this vehicle to HA in my latest attempt. I think I might have been hitting rate limits (another known issue) when I first attempted to add it to HA.
Please provide all files, they should be sanitised for personal information. Nevertheless please double check and edit out all data you're not happy to share.
The rate limiting can occur again and will be fixed soon by #462, when we don't use the old API endpoints anymore.
@rikroe Ok, here is the information: https://gist.github.com/8113c64c38f9998a75c878318725cac1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
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.