Mysensors "things" remain uninitialized after reboot or Openhab restart

New installation of Openhab and first time using the PaperUI. I’m using the Openhabian pre-built .img file running on a Raspberry Pi 4. I’m using the Development branch of the MySensors Raspberry Pi Gateway based on this pull request:

I can add the mysensors serial gateway binding and add a switch that is attached to my gateway and both are recognized however, if I reboot the pi or restart the OpenHab service the gateway will connect but the outlet attached remains uninitialized.

The log file relating to mysensors during the restart looks like this:

2020-01-01 15:35:33.778 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge
2020-01-01 15:35:33.837 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache file: given_ids.cached exist.
2020-01-01 15:35:33.842 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache (given_ids) content: [0, 4]
2020-01-01 15:35:33.859 [DEBUG] [col.serial.MySensorsSerialConnection] - Enabling connection watchdog
2020-01-01 15:35:33.864 [DEBUG] [col.serial.MySensorsSerialConnection] - Connecting to /dev/ttyUSB20 [baudRate:115200]
2020-01-01 15:35:33.865 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@9cd1fd': bundleContext
java.lang.NoSuchFieldError: bundleContext
	at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.registerDeviceDiscoveryService(MySensorsBridgeHandler.java:216) ~[?:?]
	at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.initialize(MySensorsBridgeHandler.java:86) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2020-01-01 15:35:33.887 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'mysensors:bridge-ser:a07cc25d': bundleContext
java.lang.NoSuchFieldError: bundleContext
	at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.registerDeviceDiscoveryService(MySensorsBridgeHandler.java:216) ~[?:?]
	at org.openhab.binding.mysensors.handler.MySensorsBridgeHandler.initialize(MySensorsBridgeHandler.java:86) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2020-01-01 15:35:33.924 [DEBUG] [col.serial.MySensorsSerialConnection] - Serial port event listener started
2020-01-01 15:35:33.925 [DEBUG] [col.serial.MySensorsSerialConnection] - Successfully connected to serial port.
2020-01-01 15:35:33.936 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 255;3;0;14;Gateway startup complete.
2020-01-01 15:35:33.939 [DEBUG] [rsAbstractConnection$MySensorsWriter] - Sending to MySensors: 0;0;3;0;2;
2020-01-01 15:35:33.940 [WARN ] [rsAbstractConnection$MySensorsReader] - Exception on reading from connection
java.text.ParseException: class java.lang.NumberFormatException : For input string: "Gateway startup complete."
	at org.openhab.binding.mysensors.internal.protocol.message.MySensorsMessage.parse(MySensorsMessage.java:342) ~[bundleFile:?]
	at org.openhab.binding.mysensors.internal.protocol.MySensorsAbstractConnection$MySensorsReader.run(MySensorsAbstractConnection.java:338) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2020-01-01 15:35:33.944 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 0;255;0;0;18;2.4.0-alpha
2020-01-01 15:35:33.973 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Presentation Message received
2020-01-01 15:35:33.979 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Writing on cache given_ids, content: [0,4]
2020-01-01 15:35:33.981 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 4;1;1;0;2;1
2020-01-01 15:35:33.982 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 4 found in gateway
2020-01-01 15:35:33.984 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 not present in node 4

I’ve spent about a day trying to figure this out and am ready to throw in the towel. Any help would be greatly appreciated. See post below for screenshots of my “things” before and after reboot.

58 PM 52 PM

Have you tried deleting the device things, stopping OH, cleaning cache, restarting OH and rediscover the each thing?

Well I tried deleting all of the things including the bridge and adding them back and similarly, they show as online (and they work) after adding them and linking them to items, but after a restart of either the raspberrypi or just restarting OpenHab, the bridge comes back online but the device things stay an uninitialized - bridge_uninitialized. I’ve been manually adding the bridge and device things because I don’t see an option for auto-discovery. I haven’t cleared cache though. Where is that file located?

I almost wonder if the device things are attempting to be initialized before the bridge is fully initialized and rather than failing and then retrying, they are just failing and staying in that state permanently.

Well it looks like that is what is happening. This is the event log after starting openhab. I guess the question is, why is the light device thing not reattempting to initialize after the bridge goes online?

2020-01-02 07:08:59.953 [hingStatusInfoChangedEvent] - 'mysensors:bridge-ser:a07cc25d' changed from UNINITIALIZED to INITIALIZING
2020-01-02 07:09:00.066 [hingStatusInfoChangedEvent] - 'mysensors:bridge-ser:a07cc25d' changed from INITIALIZING to UNINITIALIZED (HANDLER_INITIALIZING_ERROR): bundleContext
2020-01-02 07:09:00.073 [hingStatusInfoChangedEvent] - 'mysensors:light:381832a4' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
2020-01-02 07:09:00.168 [hingStatusInfoChangedEvent] - 'mysensors:bridge-ser:a07cc25d' changed from UNINITIALIZED (HANDLER_INITIALIZING_ERROR): bundleContext to ONLINE

Using openhabian image the commands to clean cache and tmp file are:

sudo systemctl stop openhab2

sudo openhab-cli clean-cache

sudo systemctl start openhab2 or sudo reboot

Do you have or ever had “simple mode” turned on in PaperUI? If so, turn it off and delete your things, clean cache like above, and rediscover.

1 Like

Please update the binding with this version: http://oberfoell.com/openhab2/org.openhab.binding.mysensors-2.5.0-SNAPSHOT.jar

This should help. I need to update the download!

1 Like

@TimO it looks like the new binding might be missing a dependency. I suck at everything Java though so not sure. Any help is greatly appreciated! Here’s the log:

2020-01-02 20:37:24.606 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.mysensors-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.mysensors [216]
  Unresolved requirement: Import-Package: gnu.io; version="[3.14.0,4.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

oops…forgot to do

feature:install openhab-transport-serial

. Now it works. Haven’t tested if it fixed my original problem yet but it loads :slight_smile:

Oh gentlemen…it’s MAGIC! Everything is working! The new binding is chugging along like a champ and I’ve got shiny brand new cache and tmp directories to boot. Thank you both VERY much @TimO and @H102!