Mercedes Me Binding

I have installed the latest binding 2.3-alpha and found thi sin my logfiles

2023-10-01 10:52:59.210 [INFO ] [esme.internal.handler.VehicleHandler] - Received command class org.openhab.core.library.types.QuantityType 65 for mercedesme:hybrid:a0ec3af23a:A250e:range#soc
2023-10-01 10:54:59.452 [INFO ] [ding.mercedesme.internal.utils.Utils] - Cannot transform  / timestamp: 1696150396
int_value: 720
timestamp_in_ms: 1696150396000
display_value: "12:00"
clock_hour_unit: T24H
 Display Value 12:00 into Double
2023-10-01 10:54:59.468 [INFO ] [esme.internal.handler.VehicleHandler] - Received command class org.openhab.core.library.types.QuantityType 66 for mercedesme:hybrid:a0ec3af23a:A250e:range#soc

Is that intentional?
Otherwise the binding seems to deliver normal values.

Log message needs to be deleted.
Charging end time 12:00 cannot be transformed into DateTime but meanwhile I know the int_value is minutes after midnight.Prognosed end time of charging shall be shown correctly

Weird. I’m running OpenHAB 4.0.0 and tried to install from the community marketplace (I’m happy to muck about on the command line, but for my OpenHAB install I prefer not to) and it looks like it installed the 3.4 snapshot instead of the 4.0 one.

(running on macOS 10.13.6 with Amazon’s Correto 17 JVM)

Happened to me, too.
I had to do the following:

  • Reset the permissions with “openhab-cli reset-ownership” so the entire structure is owned by the openhab user
  • Remove all items and things
  • Remove old bindings (market-place or standard) via openhab console and from filesystem (follow post here : Mercedes Me Binding - #164 by weymann
  • stop openhab
  • tidy up with “openhab-cli clean-cache”
  • restart openhab or even better the entire server.
    That should get you sorted.

Ah, but I said:

running on macOS 10.13.6

This means no openhab-cli. I get to play with filesystem permissions all by myself.

Ok, it’s installed:

 28 │ Active │  80 │ 4.1.0.202309262106     │ org.openhab.binding.mercedesme

But when I go to the bridge item to do the auth process, I see “@text/mercedesme.account.status.authorization-needed” in the status bar.

Forging ahead…

  • I can see the callback URL under Thing Properties, although it’s [server-ip-address]:8090 rather than [server-name]:8090.
  • Manually opening that in a new window doesn’t work as it’s the address of the wrong interface (there are multiple interfaces on this machine).
  • Going to the right IP address gives me step one of the auth process and shortly after I have the email from Mercedes
  • entering the PIN on the “step two” page gives me a stack trace in the browser window:
HTTP ERROR 500 com.google.gson.JsonIOException: Failed making field 'java.time.Instant#seconds' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
URI:	/mb-auth
STATUS:	500
MESSAGE:	com.google.gson.JsonIOException: Failed making field 'java.time.Instant#seconds' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
SERVLET:	org.openhab.binding.mercedesme.internal.server.AuthServlet-2d94d1b5
CAUSED BY:	com.google.gson.JsonIOException: Failed making field 'java.time.Instant#seconds' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
CAUSED BY:	java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.time.Instant.seconds accessible: module java.base does not "opens java.time" to unnamed module @35c5fce5
Caused by:

com.google.gson.JsonIOException: Failed making field 'java.time.Instant#seconds' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
	at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:23)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:203)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:112)
	at com.google.gson.Gson.getAdapter(Gson.java:531)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:137)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:211)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:112)
	at com.google.gson.Gson.getAdapter(Gson.java:531)
	at com.google.gson.Gson.fromJson(Gson.java:1057)
	at com.google.gson.Gson.fromJson(Gson.java:1016)
	at com.google.gson.Gson.fromJson(Gson.java:959)
	at com.google.gson.Gson.fromJson(Gson.java:927)
	at org.openhab.binding.mercedesme.internal.server.AuthService.saveTokenResponse(AuthService.java:227)
	at org.openhab.binding.mercedesme.internal.server.AuthService.requestToken(AuthService.java:156)
	at org.openhab.binding.mercedesme.internal.server.AuthServlet.doGet(AuthServlet.java:92)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:497)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:584)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:554)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:190)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:516)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final long java.time.Instant.seconds accessible: module java.base does not "opens java.time" to unnamed module @35c5fce5
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
	at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:20)
	... 33 more

Versions, etc.:
OpenHAB 4.0.0 Release Version
macOS 10.13.6
Java:

openjdk 17.0.8 2023-07-18 LTS
OpenJDK Runtime Environment Corretto-17.0.8.7.1 (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.8.7.1 (build 17.0.8+7-LTS, mixed mode, sharing)

Here I can only guess but you may need to bind openhab to a specific IP address under network settings.
There you can set which address should be used and if openhab should listen on a single address or all.

I believe that you should be able to ssh into it.
Alternatively chown -R openhab.openhab in the installation folders should do the trick.
Just don’t do that on root level otherwise you will have to reinstall your machine :wink:

I appreciate the assistance but I’m ok on the CLI/operating system end of things, and it looks like the plugin is installed and at the correct version. The stack trace looks like a Java reflection issue so it’s possible that by running Java 17 I’m hitting something that was permitted in Java 11 or earlier.

Should not be an issue. I am running the add-on on 4.1-snapshot so I had to download the matching jar.
According to Bernd’s post Mercedes Me Binding - #162 by weymann market place should be fine for you. It definitely supports Java 17 as that is prerequisite for Openhab 4.

Translation issue - I need to fix this

Sure, autodetect IP address works for most users which are operating on a raspi. Overwriting IP address in config will come in next version ind advanced configuration settings

Saw this error also here. To be honest I don’t know why this isn’t working for you. But I think I can provide a fix.

I figured out the reflection error. Karaf on macOS generates an unusable openHAB-wrapper.conf[1], so I’ve been hand-editing mine to a working state over however many releases without really learning what the contents of the file do. Adding --add-opens=java.base/java.time=ALL-UNNAMED to set.JDK_JAVA_OPTIONS gives wrapper the required access to the java.time.Instant class. I’ve no idea if this should be required, but making this change and restarting OpenHAB to pick it up allowed me to complete the registration process.

[1] I can’t recall the exact problem other than that it was discussed at some point in the OpenHAB community and is apparently unfixable?

New problem! :slight_smile:

Added my BEV, set the Bridge to the active bridge, added the VIN, pressed Save, opened the BEV Thing, and:

Cannot invoke “String.startsWith(String)” because “pattern” is null

Stacktrace:

2023-10-17 22:02:36.473 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.mercedesme.internal.handler.VehicleHandler@6b6bcf19': Cannot invoke "String.startsWith(String)" because "pattern" is null
java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "pattern" is null
	at org.openhab.binding.mercedesme.internal.handler.VehicleHandler.updateChannel(VehicleHandler.java:937) ~[?:?]
	at org.openhab.binding.mercedesme.internal.handler.VehicleHandler.lambda$4(VehicleHandler.java:877) ~[?:?]
	at java.util.Map.forEach(Map.java:713) ~[?:?]
	at java.util.Collections$UnmodifiableMap.forEach(Collections.java:1553) ~[?:?]
	at org.openhab.binding.mercedesme.internal.handler.VehicleHandler.distributeContent(VehicleHandler.java:766) ~[?:?]
	at org.openhab.binding.mercedesme.internal.handler.AccountHandler.registerVin(AccountHandler.java:249) ~[?:?]
	at org.openhab.binding.mercedesme.internal.handler.VehicleHandler.initialize(VehicleHandler.java:151) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) ~[?:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]

(this seems to happen when I save a change to the Thing, and is preceded by " [INFO ] [ercedesme.internal.utils.UOMObserver] - No mapping found for KM_PER_LITER" in at least two cases)

…and that seems to have been transient as my BEV Thing is now online and showing a bunch of channels. I’ll goof around with this a bit and provide any additional feedback.

1 Like

Thanks for highlighting this. Some units for combustion engines are missing.
I’ll correct this.
It’s corrected in the new version 2.4-beta including fix for authorization problem during authorization.

Minor “feature” request: can you obscure the returned access token when logging?

additional feature request: the old binding had a “last update from API” timestamp, which was handy for spotting that the API connection had failed for whatever reason. I can probably synthesise this, but it’d be nice to have it as a channel.

Sure, this won’t be part in an official release.

I’m sure you cannot use this checking successful API requests. Each item has it’s own last update timestamp.
So Binding is running fine today (Sunday). But last tire update is still from last drive on Saturday

You should listen to Thing Status Updates to identify problems in connections because if I detect problems with tokens or whatever the MercedesMe Thing will switch to offline.

ok, thanks!

@weymann I managed to get it running after updating my OH to a newer version.

It is correct that it is not possible to lock or unlock the car with this binding right? i only can see the status of the doors but can’t unlock them. Because my idea was to unlock my car automatically if I open my front door between 7 and 8 on a weekday as I go to work