Mercedes Me Binding

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

In principle it’s possible

  1. Check if your vehicle is supporting this feature => thing properties (Pic 1)
  2. In UI commands lock / unlock are already taken into account (Pic 2)
  3. Readme shows lock channel is readable and writable
    Also mapping is mentioned so you can use it in rules.
    lockItem.sendCommand(0) will lock and lockItem.sendCommand(1) will unlock your vehicle

Pic 1

Pic 2

Pic 3

I got my EQB last week and wanted to integrate into OpenHAB to basically track mileage and positions.

I finally found this extension which, after some struggling with OH, I got almost working. I authorized, the car was found, I entered the VIN and now I’m greeted with:

image

What can I do to help debug this?

Edit: As text for later reference:

HANDLER_INITIALIZING_ERROR
'void org.openhab.core.library.types.DecimalType.<init>(long)' 

I assume you installed binding via marketplace, right?

Unfortunately there are some problems in marketplace evaluating the right binding version. From the error you reported I think the wrong binding version was installed.

Which version of openHAB do you run?

I’m running openHAB 4.1.1 -Release Build- (looks like your screenshot). The binding says “Updated At
November 26, 2023 3:33 PM”.

Should I try to install the version manually?

Sadly openHAB Marketplace is mixing up versions. So first cleanup everyting mentioned in post here. (Snippet below)
Afterwards put linked jar in addons folder