Mercedes Me service drops authorization if more than one car is active with the binding.
This is reported as issue #15024 on github / openhab-addons
Context
I am not able to use more than one car along with the binding, this does not allow my intended use case (use OH for controlling charge currents sharing between multiple EVSEs)
The binding behaves fine when only a single car is active as a thing and the other thing is paused.
It seems the binding does not serialize the accesses to the Mercedes service but runs requests in parallel which causes errors.
Your Environment
openHAB 3.4.2 Release Build
MercedesMe Binding 3.4.2 from Release
In this example I am using a C300e PHEV and a EQA250+ BEV.
Things run smooth for some time then oauth error occurs:
2023-04-25 02:19:27.238 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
This does not happen if I have only one car active and the other car (thing) is paused in OH.
Expected Behavior
The MercedesMe binding should work correctly with more than one car being active as a thing
Current Behavior
If more than one car is active in the binding the authorization at Mercedes encounters an error and gets lost,
one needs to re-authorize the access at Mercedes
log:
2023-04-25 01:18:43.166 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
2023-04-25 01:18:43.173 [WARN ] [desme.internal.server.CallbackServer] - Exception getting token null
2023-04-25 01:54:17.781 [INFO ] [esme.internal.handler.VehicleHandler] - Mercedes EQA 250+:payasyoudrive Error getting data DNS timeout 15000 ms
2023-04-25 01:54:17.781 [INFO ] [esme.internal.handler.VehicleHandler] - Mercedes C300e:payasyoudrive Error getting data DNS timeout 15000 ms
2023-04-25 02:19:27.238 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
2023-04-25 02:19:27.245 [WARN ] [desme.internal.server.CallbackServer] - Exception getting token null
2023-04-25 03:20:02.292 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
2023-04-25 03:20:02.297 [WARN ] [desme.internal.server.CallbackServer] - Exception getting token null
2023-04-25 04:20:35.603 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
2023-04-25 04:20:35.609 [WARN ] [desme.internal.server.CallbackServer] - Exception getting token null
2023-04-25 05:01:11.191 [INFO ] [esme.internal.handler.VehicleHandler] - Mercedes C300e:payasyoudrive Error getting data DNS timeout 15000 ms
2023-04-25 05:01:11.191 [INFO ] [esme.internal.handler.VehicleHandler] - Mercedes EQA 250+:payasyoudrive Error getting data DNS timeout 15000 ms
2023-04-25 05:21:26.546 [ERROR] [oauth2client.internal.OAuthConnector] - grant type refresh_token to URL https://ssoalpha.dvb.corpinter.net/v1/token failed with error code invalid_request, description unknown, invalid, or expired refresh token
2023-04-25 05:21:26.551 [WARN ] [desme.internal.server.CallbackServer] - Exception getting token null
this does not happen if only one of the above cars is active and the other car (thing) is paused in OH
Possible Solution
it seems the binding tries to access both car data simultaneously at Mercedes, this causing an access token violation ( Token is already in use).
Should be fixed when access get serialized in the binding in such that one access for one car will fully complete and then the next access for the next car follows
Steps to Reproduce (for Bugs)
have at least 2 cars as things active in OH with same polling intervals,
pause both car things
pause the binding
unpause the binding
unpause both cars as fast as possible
wait, the issue can take several days to happen
countercheck