Mercedes Me Binding

Works out again. But have changed nothing now? Only confirmed up to the point where i received “status OK”.

A mercedesme.json has been stored. Thanks for your support. Will further observe this.

As said I cannot tell why the origin problem occurred. There’s no change in the binding itsself but of course after these steps are performed you received a new fresh token. You can see in the callbackUrl page scope offline_access is requested so in principle the authorization will never expire.

image

  • during runtime every refresh token call will renew the token plus the token is stored in /var/lib/openhab/jsondb/mercedesme.json
  • if you restart openHAB token is restored from mercedesme.json and it shall work fine
  • if you e.g. restore a openHAB backup from several days ago it might be possible the token is obsolete - manual request of new token is necessary

I know this isn’t convienent but currently I don’t have a better way of handling.

Hi @weymann

Question regarding update interval, i have refreshInterval=5 but it seems like its ignored ?

example from log:
12:11 next 12:33 = 22min
12:33 next 12:54 = 21min
15:54 next 13:15 = 21min
13:15 next 13:37 = 22min

Regards Mads

Just checked on my side: switched from 5 min to 1 min and back again and this worked fine for me.

I see in your screenshot the response from Mercedes API is printed as DEBUG log. This is an older version and in the meanwhile the binding has gone through the official openHAB review process with several findings fixed. The Pull Request is merged and the binding will be part in the next official OH release. If you want to see the API response messages you need to set loglevel TRACE.

Long story short:
Please remove jar file from addons folder, download again the jar from top post, it’s linked to latest version and check again with the newest version.

1 Like

Hi this morning i downloade the new version, stopped openhab, delete the old file, copy new file into folder, restarted openhab.

but is nearly still the same, now it tells me the theres no battery capacity given

I can see data regarding battery i changing

Info: im runing file based config

Regards Mads

Ok, I see.

No battery / fuel capacity isn’t a crucial problem and doesn’t harm the functionality. There are 2 newer config parameters which you can apply, see the actual readme


Based on soc and fuel level the binding is calculating how many kWh / liters

  • are still available
  • needs to be filled up for reaching 100%

These are also additional channels which are sadly not present after a simple reboot. This is a known problem and can only be solved via deleting and creating things again.
If you’ve textual configuration remove things file shortly and place it back again. Then the new channels shall appear and debug messages are gone!

Maybe this will solve also the 20 minutes updates which I cannot explain at the moment.

Hi, i have an issue with the electric range with my hybrid car. It seems that it somehow calculates the total range ( fuel plus electric ) when the item is updated.

2022-09-07 07:48:00.440 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 07:48:00.760 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 07:53:01.161 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 07:53:01.566 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 07:58:01.834 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 07:58:02.280 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 08:03:02.572 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 08:03:02.909 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 08:08:03.244 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 08:08:03.721 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 08:13:03.966 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 08:13:04.477 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 08:18:04.812 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 08:18:05.169 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km
2022-09-07 08:23:05.552 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 135 km to 0 km
2022-09-07 08:23:05.939 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GLC_Range_Electric' changed from 0 km to 135 km

mercedesme:hybrid:MercedesGLC:range#range-electric

Any thoughts on that one?
Thanks

This looks curious, I’ll check this issue

1 Like

For hybrid vehicle you’ll have

  • range-electric
  • range-fuel
  • range-hybrid → not given by Mercedes API - I sum them up inside the binding

What’s curious in the trace above is the flipping of range_electric during an update from orig value to 0 and then back again => this shall not happen. Also in my tests I cannot see this.

Please perform the following steps:

  • check on your side if you’ve the latest version installed. During development several changes were done. Link to actual jar is available on top post
  • Log into openHAB console and change debug level to TRACE: log:set TRACE org.openhab.binding.mercedesme
  • if problem still occurs send logs via private message or in this thread for further analysis

Thanks Bernd, I will have a look and let you know if the issue persists.

Unable to get it to work.
For some reason I get a very strange callback URL in openhab:

It is nevertheless configured as http://192.168.2.20:8090/mb-callback in the Mercedes API credentials and 192.168.2.20 is mentioned in my .things configuration (callbackIp)

Ahh sh*t, there’s a typo in the code which needs to be corrected.

Just to get it running:
change callbackIp to callbackIP in things config in order to check if it’s working.

1 Like

Yes, this resolved it. Thanks!

Hi Bernd, it seems the issue has been sorted with the latest version. Range electric value is showing correctly now. Thanks for your help.

1 Like

Got everything working, but still question related to the channel “batteryCapacity”

I’ve added this to my .things file:

Bridge mercedesme:account:4711   "MercedesMe" [ clientId="XXX", clientSecret="XXX", imageApiKey="XXX", callbackIP="192.168.2.20", callbackPort=8090, odoScope=true, vehicleScope=true, lockScope=true, fuelScope=true, evScope=true] {
         Thing bev eqc           "Mercedes EQC"        [ vin="XXX", refreshInterval=5, background=false, night=false, cropped=false, roofOpen=false, format="webp", batteryCapacity=80.0]
}

As you can see, I have added batteryCapacity=80.0.
My battery is 80 kWh and since it’s decimal type I’ve noted 80.0

I have then added following 2 items:

Number:Energy           EQC_charged                 "Charged Battery Energy"                    (gMBC)  {channel="mercedesme:bev:4711:eqc:range#charged"}
Number:Energy           EQC_uncharged               "Uncharged Battery Energy"                  (gMBC)  {channel="mercedesme:bev:4711:eqc:range#uncharged"}

However, the values don’t populate and the state remains at UNDEF.

Have I made a mistake somewhere in the syntax of my things or items file?

Updated to 3.4.0-SNAPSHOT #3086 and get the following account thing error now:

HANDLER_INITIALIZING_ERROR

cannot assign instance of java.time.LocalDateTime to field org.openhab.core.auth.client.oauth2.AccessTokenResponse.createdOn of type java.time.Instant in instance of org.openhab.core.auth.client.oauth2.AccessTokenResponse

Also can’t longer used the callback URL. Get “error connection refused”.

Any idea what this is?

Don’t see issues at the first glance.
Is Battery State of Charge range#soc updated and deliveres a valid percentage value?

  1. Please double check if you’re on the latest version.
  2. Activate TRACE level to have all API responses in the log.
  3. If SoC value is delivered charged and uncharged values are calculated immediately, if batteryCapacity is configured well.
    Otherwise you shall see debug log No battery capacity given

My current assumption:
The Mercedes Me binding is now an official part of openHAB. Especially the members who installed the Marketplace binding before are facing suspicious errors, after update to new Milestone. Root cause seems to be conflicting bundle versions between Marketplace installation and Milestone release.
As said this is an assumption but it matches with a parallel discussion of conflicting bindings.

Please check via this thread if you
a) have 2 times a mercedes bundle with different version and
b) if you can resolve this conflict with the below description

This is caused by an API breaking change introduced in 3.4M2:

So the binding needs to be compiled after this change, i.e. it must be at least as new. To make matters worse, unfortunately this change introduced a regression which has also been fixed, but only after M2:

So if you are able to update to latest snapshot (both core and the binding), everything should be fine. This fix will be included in 3.4M3.

Please let me know if you are seeing anything similar to this after upgrading to latest version.

1 Like

Great support, thanks for this. Works out again.

1 Like