Closed Yixi closed 2 years ago
@rikroe @muxiachuixue I tried
20220511.2
, It appears that periodic unavailable, seems one hour. The strategy of token refresh has some defects?
I have seen the 'unvailable' situation this morning, but not in a periodic way. Need more time to find out. In addition, the log reported these warnings:
Logger: bimmer_connected.utils
Source: /usr/local/lib/python3.9/site-packages/bimmer_connected/utils.py:79
First occurred: 09:50:26 (32 occurrences)
Last logged: 11:00:44
DeprecationWarning:/config/custom_components/bmw_connected_drive/lock.py:87: 'VehicleStatus.door_lock_state' is deprecated. Please change to 'vehicle.doors_and_windows.door_lock_state'.
DeprecationWarning:/config/custom_components/bmw_connected_drive/lock.py:94: 'VehicleStatus.door_lock_state' is deprecated. Please change to 'vehicle.doors_and_windows.door_lock_state'.
Logger: custom_components.bmw_connected_drive.coordinator
Source: custom_components/bmw_connected_drive/coordinator.py:54
Integration: BMW Connected Drive
First occurred: 10:45:38 (1 occurrences)
Last logged: 10:45:38
Unexpected error fetching bmw_connected_drive-xxxxxxxx data: The connection pool was closed while 1 HTTP requests/responses were still in-flight.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/bimmer_connected/account.py", line 78, in get_vehicles
vehicles_responses: List[httpx.Response] = await asyncio.gather(*vehicles_tasks)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1729, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1506, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1593, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1621, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1679, in _send_handling_redirects
raise exc
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1661, in _send_handling_redirects
await hook(response)
File "/usr/local/lib/python3.9/site-packages/bimmer_connected/api/utils.py", line 36, in raise_for_status_event_handler
response.raise_for_status()
File "/usr/local/lib/python3.9/site-packages/httpx/_models.py", line 1510, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1652496338066&tireGuardMode=ENABLED'
For more information check: https://httpstatuses.com/401
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/bmw_connected_drive/coordinator.py", line 54, in _async_update_data
await self.account.get_vehicles()
File "/usr/local/lib/python3.9/site-packages/bimmer_connected/account.py", line 87, in get_vehicles
self.vehicles.append(MyBMWVehicle(self, vehicle_dict))
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1975, in __aexit__
await self._transport.__aexit__(exc_type, exc_value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 332, in __aexit__
await self._pool.__aexit__(exc_type, exc_value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 326, in __aexit__
await self.aclose()
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 312, in aclose
raise RuntimeError(
RuntimeError: The connection pool was closed while 1 HTTP requests/responses were still in-flight.
I have seen the 'unvailable' situation this morning, but not in a periodic way. Need more time to find out. In addition, the log reported these warnings:
I have the same logs, in periodic way, exactly in one hour period.
Client error '401 Unauthorized' for url 'https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1652496338066&tireGuardMode=ENABLED'
is probably due to the fact that EXPIRES_AT_OFFSET
is not large enough. Depending on the time the actual requests to BMW take, we might send a request with the old token but BMW already thinks it is expired.
Can you try increasing it to 30 seconds and see if that helps?
Also thanks for the information regarding door_lock_state
, I missed this somehow and will change (but good to see it's still working anyhow :) )
Client error '401 Unauthorized' for url 'https://myprofile.bmw.com.cn/eadrax-vcs/v1/vehicles?apptimezone=480.0&appDateTime=1652496338066&tireGuardMode=ENABLED'
is probably due to the fact thatEXPIRES_AT_OFFSET
is not large enough. Depending on the time the actual requests to BMW take, we might send a request with the old token but BMW already thinks it is expired.Can you try increasing it to 30 seconds and see if that helps?
Also thanks for the information regarding
door_lock_state
, I missed this somehow and will change (but good to see it's still working anyhow :) )
I have modified the EXPIRES_AT_OFFSET to 30 s. Let's see what happens. BTW, in Siri shortcuts, if the program finds out the access_token to be invalid, it will get a new access_token from the refresh_token.
BTW, in Siri shortcuts, if the program finds out the access_token to be invalid, it will get a new access_token from the refresh_token.
This should happen here as well. I suspect a race condition of sorts. I'll investigate this. If 30 seconds is not enough, try increasing to 300 seconds.
Could you please try using 0.9.0b12
? Just replace it in the manifest of the custom component.
Cannot test it myself as my chinese account doesn't have vehicles added...
@rikroe I am glad to test it, and will give you feedback ASAP. :-)
BTW, in Siri shortcuts, if the program finds out the access_token to be invalid, it will get a new access_token from the refresh_token.
This should happen here as well. I suspect a race condition of sorts. I'll investigate this. If 30 seconds is not enough, try increasing to 300 seconds.
30s does not work. However, 300s works. The error has not appeared in the past several days.
30s does not work
@rikroe @muxiachuixue It dose not work in 0.9.0b12
.
It will be unavailable for about 5 minutes every hour
30s does not work. However, 300s works. The error has not appeared in the past several days.
@rikroe can you bump a new version with this period?
Please try updating to 0.9.0b13.
I have literally no idea why you guys are getting this error message. I tried all types of debugging agains the chinese APIs and it worked for me all the time :/ Therefore, just reduced the token expiration by 300 seconds.
@rikroe It seems better, but the unavailable state still showed up, but only last for 2 seconds. :-(
@rikroe It seems better, but the unavailable state still showed up, but only last for 2 seconds. :-(
Same for me. The unavailable state showed up once per hour periodically and lasted for 2 seconds each time.
Please try the latest custom component which now should retry if a 401 error occurs.
EDIT: Seems as if I missed something... You'll need to update to b16
/the respective custom component when it's out.
Please try out the latest custom component, 20220522.1. This should fix your issues (i.e. ignores the expiry date but just gets a new token once a HTTP 401 Unauthorized
occurs).
If I get feedback until tomorrow, the proper HA PR could make it to the 2022.6
release.
Please try out the latest custom component, 20220522.1. This should fix your issues (i.e. ignores the expiry date but just gets a new token once a
HTTP 401 Unauthorized
occurs). If I get feedback until tomorrow, the proper HA PR could make it to the2022.6
release.
I have tried the latest version 20220522.1
. Now no error exists. The unavailable state in the history is no longer seen. Thanks for debugging.
Closing this as the issue is solved with the custom component. Also the new library version will be included in the official HA 2022.6 release. Thanks again guys for your support in getting it back running 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
Home assistant BMW login has error from these days:
Authentication error: {"data":null,"code":499100,"error":true,"msgType":"toast","description":"请前往应用市场获取最新版本"} 08:44:28 – (ERROR) /usr/local/lib/python3.9/site-packages/bimmer_connected/api/utils.py
the "请前往应用市场获取最新版本" means "Please go to the App Market for the latest version"
Expected behavior
login success
Which Home Assistant version are you using?
2022.3.8
What was the last working version of Home Assistant Core?
2022.3.8
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