Mercedes Me Binding

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

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