Mercedes Me (Connected Vehicle)

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote: Tuesday 10 August 2021 17:27 @kiddigital
Is there a way to send commands to the car?
At the moment not.. as far as I know, none of the current BYOCAR API's has options to send data TO the car. It is retrieval only.

And from a development side, I know for sure that we are not sending anything back :)
rolandbreedveld wrote: Tuesday 10 August 2021 17:27 I'm looking for a way to stop/start charging, when my solar panels are producing energy.
That is indeed a very nice use-case. Hopefully Mercedes reads along and also considers it a good idea ;)
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

Hi All
Since I have my Mercedes for almost a month, I had to recreate the token 3 times, also if Domoticz is restarted the token should be recreated.
I don't like that!
So I created a script which does the token stuff automatically.
It can be done by hand or, as in my case, running from cron on a linux server with GUI from cron each week.

I have no idea if this can be done with curl or wget, so the trick is to start chrome in debug-mode with the auth url and grep the token from the log-file.

What you need:
- a linux pc with chrome, strings and curl installed
- first time running, you have to login and store username/password in Chrome
- if running this script from the cron tab, make sure the GUI session of the user is running.
- the Domoticz API must be enabled for your pc
Think this also should run on my Raspberry Pi which is running Domoticz, it's not tested because I don't want a GUI installed on it.

Don't forget to change the script with your parameters.

regards, Roland
Attachments
get_mercedes_token.txt
(3.17 KiB) Downloaded 97 times
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Mercedes Me (Connected Vehicle)

Post by kiddigital »

@rolandbreedveld , that is weird. It should not be needed as the Domoticz module should use the refreshtoken to get a new token when needed.

Can you check your log to see why Domoticz does not get a new token using the refreshtoken?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Saturday 21 August 2021 16:45 @rolandbreedveld , that is weird. It should not be needed as the Domoticz module should use the refreshtoken to get a new token when needed.

Can you check your log to see why Domoticz does not get a new token using the refreshtoken?
Hi kiddigital

Found out, it started with a scheduled reboot of my internet modem, exactly at 4:00:

# here everything is fine:
2021-08-19 03:54:48.389 EQA250: General/Percentage (EQA250 Battery Level)
2021-08-19 03:54:48.403 EQA250: General/Custom Sensor (EQA250 Odometer)
2021-08-19 03:54:48.417 EQA250: General/Alert (EQA250 Open Alert)

# No internet:
2021-08-19 04:00:00.442 Status: EQA250: Found non-standard resultcode (28) in HTTP response statusline: HTTP/1.1 28 Timeout was reached
2021-08-19 04:00:00.442 Error: EQA250: Failed to perform GET request (28)!
2021-08-19 04:00:00.442 Status: EQA250: Found non-standard resultcode (28) in HTTP response statusline: HTTP/1.1 28 Timeout was reached
2021-08-19 04:00:00.442 Status: EQA250: Received (Curl) returncode 28.. API request response took too long, timed-out!

# After restoring internet connection:
2021-08-19 04:01:47.765 Error: EQA250: Failed to perform GET request (401)!
2021-08-19 04:01:47.765 Status: EQA250: Received 400/401.. Let's try to (re)authorize again!
2021-08-19 04:01:57.950 Status: EQA250: Found non-standard resultcode (35) in HTTP response statusline: HTTP/1.1 35 SSL connect error
2021-08-19 04:01:57.951 Error: EQA250: Failed to perform POST request (35)!
2021-08-19 04:01:57.951 Status: EQA250: Found non-standard resultcode (35) in HTTP response statusline: HTTP/1.1 35 SSL connect error
2021-08-19 04:01:57.951 Status: EQA250: Received unhandled HTTP returncode 35 !
2021-08-19 04:01:57.951 Error: EQA250: Failed to get token.
2021-08-19 04:01:57.951 Error: EQA250: Failed to refresh login credentials.
2021-08-19 04:01:57.951 Error: EQA250: No access token available.
2021-08-19 04:01:57.951 Error: EQA250: Failed to get awake state (available resources)!
2021-08-19 04:01:57.952 Status: EQA250: Car awake detection: Car asleep
2021-08-19 04:01:57.964 EQA250: General/Alert (EQA250 State)
2021-08-19 04:02:57.972 Error: EQA250: No access token available.
2021-08-19 04:02:57.972 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: Failed to get awake state (available resources)!
2021-08-19 04:03:57.980 Error: EQA250: No access token available.
2021-08-19 04:03:57.980 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: Failed to get awake state (available resources)!
# and so on repeating
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Saturday 21 August 2021 16:45 @rolandbreedveld , that is weird. It should not be needed as the Domoticz module should use the refreshtoken to get a new token when needed.

Can you check your log to see why Domoticz does not get a new token using the refreshtoken?
and after restarting Domoticz, worker will be disabled:

2021-08-21 17:53:16.898 Status: EQA250: Worker stopped...
2021-08-21 17:53:20.959 Status: EQA250: Using Domoticz home location (Lat 51.826431, Lon 4.643202) as car's home location.
2021-08-21 17:53:20.959 Status: EQA250: Worker started...
2021-08-21 17:53:21.959 EQA250: Attempting login (using provided Authorization code).
2021-08-21 17:53:22.429 Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-21 17:53:22.429 Error: EQA250: Failed to get token.
2021-08-21 17:53:22.429 Error: EQA250: Login unsuccessful!
2021-08-21 17:53:23.430 EQA250: Attempting login (using provided Authorization code).
2021-08-21 17:53:23.824 Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-21 17:53:23.865 Error: EQA250: Failed to get token.
2021-08-21 17:53:23.865 Error: EQA250: Login unsuccessful!
2021-08-21 17:53:24.865 EQA250: Attempting login (using provided Authorization code).
2021-08-21 17:53:25.285 Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-21 17:53:25.285 Error: EQA250: Failed to get token.
2021-08-21 17:53:25.285 Error: EQA250: Login unsuccessful!
2021-08-21 17:53:26.285 EQA250: Attempting login (using provided Authorization code).
2021-08-21 17:53:26.666 Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-21 17:53:26.666 Error: EQA250: Failed to get token.
2021-08-21 17:53:26.666 Error: EQA250: Login unsuccessful!
2021-08-21 17:53:26.666 Error: EQA250: Aborting due to too many failed authentication attempts (and prevent getting blocked)!
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

Running my script, and it works again:

2021-08-21 17:55:27.509 Status: EQA250: Worker stopped...
2021-08-21 17:55:27.548 Status: EQA250: Using Domoticz home location (Lat 51.82xxxxx, Lon 4.64xxxxx) as car's home location.
2021-08-21 17:55:27.549 Status: EQA250: Worker started...
2021-08-21 17:55:28.549 EQA250: Attempting login (using provided Authorization code).
2021-08-21 17:55:28.937 Status: EQA250: Received new refresh token l9ulkvBxxxxxxxxxxxxxxxx7nmlE378Sgp8 .
2021-08-21 17:55:28.937 EQA250: Login successful.
2021-08-21 17:55:30.766 Status: EQA250: Found 25 resource fields: rangeliquid,tanklevelpercent,soc,rangeelectric,readingLampFrontRight,windowstatusfrontright,rooftopstatus,windowstatusfrontleft,sunroofstatus,doorstatusfrontright,doorstatusfrontleft,doorstatusrearright,interiorLightsFront,readingLampFrontLeft,decklidstatus,windowstatusrearright,windowstatusrearleft,lightswitchposition,doorstatusrearleft,interiorLightsRear,doorlockstatusdecklid,doorlockstatusvehicle,doorlockstatusgas,positionHeading,odo
2021-08-21 17:55:30.766 Status: EQA250: Car awake detection: Car awake
2021-08-21 17:55:32.215 Status: EQA250: Executing command: Get All states
2021-08-21 17:55:34.447 EQA250: General/Percentage (EQA250 Battery Level)
2021-08-21 17:55:34.468 EQA250: General/Custom Sensor (EQA250 Odometer)
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote:
kiddigital wrote: Saturday 21 August 2021 16:45 @rolandbreedveld , that is weird. It should not be needed as the Domoticz module should use the refreshtoken to get a new token when needed.

Can you check your log to see why Domoticz does not get a new token using the refreshtoken?
Hi kiddigital

Found out, it started with a scheduled reboot of my internet modem, exactly at 4:00:

# here everything is fine:
2021-08-19 03:54:48.389 EQA250: General/Percentage (EQA250 Battery Level)
2021-08-19 03:54:48.403 EQA250: General/Custom Sensor (EQA250 Odometer)
2021-08-19 03:54:48.417 EQA250: General/Alert (EQA250 Open Alert)

# No internet:
2021-08-19 04:00:00.442 Status: EQA250: Found non-standard resultcode (28) in HTTP response statusline: HTTP/1.1 28 Timeout was reached
2021-08-19 04:00:00.442 Error: EQA250: Failed to perform GET request (28)!
2021-08-19 04:00:00.442 Status: EQA250: Found non-standard resultcode (28) in HTTP response statusline: HTTP/1.1 28 Timeout was reached
2021-08-19 04:00:00.442 Status: EQA250: Received (Curl) returncode 28.. API request response took too long, timed-out!

# After restoring internet connection:
2021-08-19 04:01:47.765 Error: EQA250: Failed to perform GET request (401)!
2021-08-19 04:01:47.765 Status: EQA250: Received 400/401.. Let's try to (re)authorize again!
2021-08-19 04:01:57.950 Status: EQA250: Found non-standard resultcode (35) in HTTP response statusline: HTTP/1.1 35 SSL connect error
This is where things go wrong. Here the MercedesMe module tries to get a new token but when trying to connect to the Mercedes API, something goes wrong in setting up a secure HTTPS connection. The underlying Curl and SSL libraries used by the module (and at many other places in Domoticz) somehow ‘conflict’ with the SSL libraries at the other end (Mercedes API).

Could you try to run with some Debug flags enabled to see if additional logging gives some more clues? (At least ‘received’ flag).

Maybe try to upgrade the SSL libraries of the Domoticz machine (Pi, Windows?).

rolandbreedveld wrote:2021-08-19 04:01:57.951 Error: EQA250: Failed to perform POST request (35)!
2021-08-19 04:01:57.951 Status: EQA250: Found non-standard resultcode (35) in HTTP response statusline: HTTP/1.1 35 SSL connect error
2021-08-19 04:01:57.951 Status: EQA250: Received unhandled HTTP returncode 35 !
2021-08-19 04:01:57.951 Error: EQA250: Failed to get token.
2021-08-19 04:01:57.951 Error: EQA250: Failed to refresh login credentials.
2021-08-19 04:01:57.951 Error: EQA250: No access token available.
2021-08-19 04:01:57.951 Error: EQA250: Failed to get awake state (available resources)!
2021-08-19 04:01:57.952 Status: EQA250: Car awake detection: Car asleep
2021-08-19 04:01:57.964 EQA250: General/Alert (EQA250 State)
2021-08-19 04:02:57.972 Error: EQA250: No access token available.
2021-08-19 04:02:57.972 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: No access token available.
2021-08-19 04:02:57.973 Error: EQA250: Failed to get awake state (available resources)!
2021-08-19 04:03:57.980 Error: EQA250: No access token available.
2021-08-19 04:03:57.980 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: No access token available.
2021-08-19 04:03:57.981 Error: EQA250: Failed to get awake state (available resources)!
# and so on repeating
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

@kiddigital
thanxz for your reaction
This is where things go wrong. Here the MercedesMe module tries to get a new token but when trying to connect to the Mercedes API, something goes wrong in setting up a secure HTTPS connection. The underlying Curl and SSL libraries used by the module (and at many other places in Domoticz) somehow ‘conflict’ with the SSL libraries at the other end (Mercedes API).

Could you try to run with some Debug flags enabled to see if additional logging gives some more clues? (At least ‘received’ flag).
This is with all debugging on, at restart of Domoticz,
(error is different on restart and after loosing temporary the internet connection)

Code: Select all

2021-08-25 13:26:05.749  [667f4220] EQA250: Attempting login (using provided Authorization code).
2021-08-25 13:26:05.749  [667f4220] Debug: EQA250: Performing request to Api: https://id.mercedes-benz.com/as/token.oauth2
021-08-25 13:26:06.113  [667f4220] Debug: EQA250: Performed request to Api: (400)
{"error_description":"Authorization code is invalid or expired.","error":"invalid_grant"}
Response headers: HTTP/1.1 400 Bad RequestDate: Wed, 25 Aug 2021 11:26:06 GMTContent-Type: application/json;charset=utf-8Transfer-Encoding: chunkedConnection: keep-aliveX-Frame-Options: SAMEORIGINReferrer-Policy: originCache-Control: no-cache, no-storePragma: no-cacheExpires: Thu, 01 Jan 1970 00:00:00 GMTSet-Cookie: PF=W9eE2KxAqzTUZaP3DGgYye;Path=/;Secure;HttpOnlyContent-Security-Policy: frame-ancestors 'none'X-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=block
2021-08-25 13:26:06.113  [667f4220] Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-25 13:26:06.113  [667f4220] Error: EQA250: Failed to get token.
2021-08-25 13:26:06.113  [667f4220] Error: EQA250: Login unsuccessful!
2021-08-25 13:26:07.114  [667f4220] EQA250: Attempting login (using provided Authorization code).
2021-08-25 13:26:07.114  [667f4220] Debug: EQA250: Performing request to Api: https://id.mercedes-benz.com/as/token.oauth2
Maybe try to upgrade the SSL libraries of the Domoticz machine (Pi, Windows?).
I'm running openssl 1.1.1 on a today updated raspberry Pi, running raspbian 5.10.17-v7+
for Domoticz I'm running 2021.1 (latest stable-version)
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Tuesday 10 August 2021 18:21
rolandbreedveld wrote: Tuesday 10 August 2021 17:27 I'm looking for a way to stop/start charging, when my solar panels are producing energy.
That is indeed a very nice use-case. Hopefully Mercedes reads along and also considers it a good idea ;)
I contacted Mercedes development, this is their reaction:
"This feature is a great idea and has been asked for frequently. We are actively investigating and researching it, but cannot at this point give any details on a rollout plan. Unfortunately we do not have any timeline that we could provide you at this stage."
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote:@kiddigital
thanxz for your reaction
This is where things go wrong…
This is with all debugging on, at restart of Domoticz,
(error is different on restart and after loosing temporary the internet connection)

Code: Select all

2021-08-25 13:26:05.749  [667f4220] EQA250: Attempting login (using provided Authorization code).
2021-08-25 13:26:05.749  [667f4220] Debug: EQA250: Performing request to Api: https://id.mercedes-benz.com/as/token.oauth2
021-08-25 13:26:06.113  [667f4220] Debug: EQA250: Performed request to Api: (400)
{"error_description":"Authorization code is invalid or expired.","error":"invalid_grant"}
Response headers: HTTP/1.1 400 Bad RequestDate: Wed, 25 Aug 2021 11:26:06 GMTContent-Type: application/json;charset=utf-8Transfer-Encoding: chunkedConnection: keep-aliveX-Frame-Options: SAMEORIGINReferrer-Policy: originCache-Control: no-cache, no-storePragma: no-cacheExpires: Thu, 01 Jan 1970 00:00:00 GMTSet-Cookie: PF=W9eE2KxAqzTUZaP3DGgYye;Path=/;Secure;HttpOnlyContent-Security-Policy: frame-ancestors 'none'X-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=block
2021-08-25 13:26:06.113  [667f4220] Status: EQA250: Received 400/401.. During authorisation proces. Aborting!
2021-08-25 13:26:06.113  [667f4220] Error: EQA250: Failed to get token.
2021-08-25 13:26:06.113  [667f4220] Error: EQA250: Login unsuccessful!
2021-08-25 13:26:07.114  [667f4220] EQA250: Attempting login (using provided Authorization code).
2021-08-25 13:26:07.114  [667f4220] Debug: EQA250: Performing request to Api: https://id.mercedes-benz.com/as/token.oauth2

I'm running openssl 1.1.1 on a today updated raspberry Pi, running raspbian 5.10.17-v7+
for Domoticz I'm running 2021.1 (latest stable-version)
This is indeed a different error (code 400). Most likely because the acces code used is not valid anymore. These codes have a very limited lifespan of only a few hours. You have to go through the login process again.

The MercedesMe module in the latest Beta now contains a little more verbose debug log and should report more details when error code 35 occurs (the one you seem to have when the router is restarted at night).

Hopefully the debug log can tell us a little more when error code 35 occurs.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote:
kiddigital wrote: Tuesday 10 August 2021 18:21
rolandbreedveld wrote: Tuesday 10 August 2021 17:27
I contacted Mercedes development, this is their reaction:
We have to wait and see Image I also heard from them that many new feature are being considered and developed but also that security and privacy concern have to be addressed carefully. Once new feature become available I hope to implement them asap.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Wednesday 25 August 2021 21:29 The MercedesMe module in the latest Beta now contains a little more verbose debug log and should report more details when error code 35 occurs (the one you seem to have when the router is restarted at night).

Hopefully the debug log can tell us a little more when error code 35 occurs.
I upgraded to the latest beta (2021.1 / 13482)
same issue, when restarting domoticz:

Code: Select all

2021-08-29 11:16:34.686  Debug: EQA250: Performed request to Api: (400)
{"error_description":"Authorization code is invalid or expired.","error":"invalid_grant"}
Response headers: HTTP/1.1 400 Bad RequestDate: Sun, 29 Aug 2021 09:16:34 GMTContent-Type: application/json;charset=utf-8Transfer-Encoding: chunkedConnection: keep-aliveX-Frame-Options: SAMEORIGINReferrer-Policy: originCache-Control: no-cache, no-storePragma: no-cacheExpires: Thu, 01 Jan 1970 00:00:00 GMTSet-Cookie: PF=W9eE2KxAqzTUZaP3DGgYye;Path=/;Secure;HttpOnlyContent-Security-Policy: frame-ancestors 'none'X-Content-Type-Options: nosniffX-XSS-Protection: 1; mode=block
2021-08-29 11:16:34.686  Status: EQA250: Received (400) Bad Request.. Unexpected unless something has changed! ({"error_description":"Authorization code is invalid or expired.","error":"invalid_grant"})
2021-08-29 11:16:34.686  Error: EQA250: Failed to get token.
2021-08-29 11:16:34.686  Error: EQA250: Login unsuccessful!
will also try to simulate the oher issue (broken internet connection)
regards, Roland
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by kiddigital »

When receiving the 400 code, you have to go through the login procedure again and enter the received code into Domoticz.

With this new (valid) code, the module should receive a new token and refresh token. As long as the module keeps running, it will use the refresh token when the token has expired and get a new token and a new refresh token each time.

If the module does not run and gets restarted and both the token and refresh token have expired, you will get the 400 again and need to login.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Wednesday 25 August 2021 21:29 The MercedesMe module in the latest Beta now contains a little more verbose debug log and should report more details when error code 35 occurs (the one you seem to have when the router is restarted at night).
Plugged out the network from my pi for 10 minutes, after that the Mercedes plugin is picking op the connection, thats great !
thanxzz for fixing this part ! :)

log-part when replug the network:

Code: Select all

2021-08-29 11:48:40.154  Status: EQA250: Received (Curl) returncode 28.. API request response took too long, timed-out!
2021-08-29 11:48:40.154  Debug: EQA250: Performing request to Api: https://api.mercedes-benz.com/vehicledata/v2/vehicles/W1N24xxxxxx1023/resources
2021-08-29 11:48:41.230  Debug: EQA250: Performed request to Api: (200)
2021-08-29 11:48:41.231  Debug: EQA250: CRC32 of content is the same.. skipping processing
2021-08-29 11:48:41.231  Debug: EQA250: Awake state checked. We are awake.
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Sunday 29 August 2021 11:45 If the module does not run and gets restarted and both the token and refresh token have expired, you will get the 400 again and need to login.
Running my script every time I start Domoticz, that works fine as work-arround for now. ;)
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by kiddigital »

Mercedes-Benz (Daimler) has posted a nice article about the Mercedes Me integration in Domoticz :)

See https://developer.mercedes-benz.com/inspire/domoticz

Thx Mercedes :D
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote:Hi All
Since I have my Mercedes for almost a month, I had to recreate the token 3 times, also if Domoticz is restarted the token should be recreated.
I don't like that!



regards, Roland
As mentioned earlier I would expect that it should not be needed to re-login after a Domoticz restart as it should use the stored Refresh-token (assuming it is still valid) to get a new Access token.

But I found that storing the Refresh token seems to fail on Raspberry Pi. And maybe on other (32-bit) platforms?

What platform do you run on?

Can you check that value of the ‘mercedesme_refreshtoken’ under the ‘UserVariables’ menu? If it is empty, than storing the Refresh token has failed. Trying to find out why.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

Hi Kiddigital
kiddigital wrote: Tuesday 12 October 2021 7:31 But I found that storing the Refresh token seems to fail on Raspberry Pi. And maybe on other (32-bit) platforms?

What platform do you run on?
Yes I'm using a Rapberry Pi4 running 32 bit Raspbian, latest version.
Domoticz 2021.1 (build 13482)
(Still no official 64 bit Raspbian, also no 64 bit Domoticz for Raspbian.)
kiddigital wrote: Tuesday 12 October 2021 7:31 Can you check that value of the ‘mercedesme_refreshtoken’ under the ‘UserVariables’ menu? If it is empty, than storing the Refresh token has failed. Trying to find out why.
The variable (string) mercedesme_refreshtoken, indeed, is empty.
Last update time is the day I activated the Mercedes-Me plugin, so it's never updated.
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by kiddigital »

rolandbreedveld wrote: Tuesday 12 October 2021 10:07 Hi Kiddigital
kiddigital wrote: Tuesday 12 October 2021 7:31 But I found that storing the Refresh token seems to fail on Raspberry Pi. And maybe on other (32-bit) platforms?

What platform do you run on?
Yes I'm using a Rapberry Pi4 running 32 bit Raspbian, latest version.
Domoticz 2021.1 (build 13482)
(Still no official 64 bit Raspbian, also no 64 bit Domoticz for Raspbian.)
kiddigital wrote: Tuesday 12 October 2021 7:31 Can you check that value of the ‘mercedesme_refreshtoken’ under the ‘UserVariables’ menu? If it is empty, than storing the Refresh token has failed. Trying to find out why.
The variable (string) mercedesme_refreshtoken, indeed, is empty.
Last update time is the day I activated the Mercedes-Me plugin, so it's never updated.
With Beta build 13737 (all platforms, but especially the 32-bit ARM for the Pi) the issue with the Refresh token not being stored correctly (see UserVariables) on 32-bit platforms has been solved. Now when restarting Domoticz, the MercedesMe module or even the whole Pi, the Refreshtoken can be retrieved and used (when still valid ofcourse) to get a new Access Token.

No more need to (re)login everytime (or run a script to perform the login ;) )

Let me know if it works for you as well?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
rolandbreedveld
Posts: 156
Joined: Wednesday 09 March 2016 11:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Mercedes Me (Connected Vehicle)

Post by rolandbreedveld »

kiddigital wrote: Tuesday 19 October 2021 19:52 With Beta build 13737 (all platforms, but especially the 32-bit ARM for the Pi) the issue with the Refresh token not being stored correctly (see UserVariables) on 32-bit platforms has been solved. Now when restarting Domoticz, the MercedesMe module or even the whole Pi, the Refreshtoken can be retrieved and used (when still valid ofcourse) to get a new Access Token.

No more need to (re)login everytime (or run a script to perform the login ;) )

Let me know if it works for you as well?
Hi Kiddigital

I can confirm that this works on a RPI4 Raspbian 32bit !
The token is stored now as variable, and on Domotics restart automatically refreshed.

Works great ! Thanxz 4 this! :D :D :D

regards, Roland
Raspberry Pi(SSD)+UPS HAT,Dashticz on WallTablet,HomeBridge, P1, HarmonyHub,FritzBox,API to 123Solar+ABB-PowerOne+SMA,ESP-Leds(flashed LSC),Tasmota,Shelly,MQTT,Mosquito,Node-Red,http://wiki.breedveld.net/index.php?title=RPiWaterMeter, Mercedes-Me
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest