Openhab totally messed up after restart: Xiaomi Door Sensors are opening by itself

Hello Community,

I got some serious problems with my openhab 2.

I am running a openhabianpi and have the following bindings in use:
Hue binding
Xiaomi mi home
Mqtt 1 & 2

Plus some others like led wifi, nothing major I think.

The longest time I had no persistence set up and did that recently with mapdb. Unfortunately I think it never really worked like I expected. The system was after a reboot not ready like it was before the reboot. A little hard to explain. Rules took a while to work and bindings needed uninstall and reinstall… so I think thats not how it was suppose to be.

Anyway, since yesterday my openhab is totally messed up after a restart. My hue binding is asking for a userid. And when i see in the logs that i should press the bridge button, nothing happens either. All the sudden the deinstalled denonmarantz binding is back eventhough im using the denon 1 binding. My xiaomi sensors are not working anymore… my mqtt is working BUT the devices i have on zigbee2mqtt are not showing in the logs eventhough i have them in my item files like before (and all the necessary transformations are there too). I checked in the console also if zigbee2mqtt is maybe just not running, but that is not the case. It is in fact up amd running just not showing in openhab. So some off my rules are not getting the proper triggers and are not working because of that.

All together, a big mess. I am wondering what I can do? I uninstalled and reinstaled hue multiple times, deleted the thing… nothing.

How can I get my way thru that mess? How should I start? Tips? Is the persistence maybe a factor here?

Thanks in advance!!

Persistence is not a factor here.

First thing to try is Clear the Cache.

How long have you been running on this SD card. It’s very unlikely but it could be the case that the SD card is wearing out, or if the machine has suddenly lost power the file system can become corrupt.

If clearing the cache doesn’t help and you are reasonably confident the SD card is fine, you will need to address this one step at a time. Pick one of the bindings and start tracing the data as close to the source as possible to OH and through the parts of OH.

For example, check the zigbee2mqtt logs to make sure it is publishing messages. Then use an MQTT client to see if you can get those messages. Then put the MQTT binding on OH into debug or trace logging and see if you can see the messages being received. Then check events.log to see if you can see the Items updating and changing. then check your sitemap/HABPanel to see if you can see the values updating.

You need to identify where in this chain the problem lies in order to know where to look for the problem.

Thank you for your help.
Clearing the cache solved some issues. But for some reasons I started openhab in the terminal and when I shut that down it shuts down openhab. I am not able to start it any other way. I tried reboot openhab and sudo /bin/systemctl start openhab2.service but I only get this in the log:

2019-03-08 10:59:13.820 [SEVERE] [org.apache.karaf.main.Main] - Could not launch framework

java.lang.RuntimeException: Error initializing storage.

at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(

at org.eclipse.osgi.launch.Equinox.<init>(

at org.eclipse.osgi.launch.EquinoxFactory.newFramework(

at org.apache.karaf.main.Main.launch(

at org.apache.karaf.main.Main.main(

Caused by: /var/lib/openhab2/cache/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)

at Method)



at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(

at org.eclipse.osgi.storagemanager.StorageManager.lock(






at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(

… 4 more

What now??

this here basically appears also on my screen:

Don’t use addons.cfg is a tip of mine, that will cause random install/uninstalls.

Don’t remove cache directories only files inside. Make sure openHAB has access to the cache directories.

Prefer REST created (paper UI) things and items over .things and .item files. Prefer JavaScript/jyphon over classic rules. All xtend based input files like the mentioned ones are heavily relying on the cache and cache consistency.

Thank you, I am not entirely sure what you mean… Sorry!

First of all, how do I get my system up again? Right now I am fighting with that error above.

EDIT: right now I am here:
openhabian@openHABianPi:~$ sudo /bin/systemctl status openhab2.service
[sudo] password for openhabian:
● openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Fri 2019-03-08 11:17:36 CET; 1h 7min ago
Process: 21077 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=1/FAILURE)
Process: 20968 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (code=exited, status=255)
Main PID: 20968 (code=exited, status=255)

Mar 08 11:17:35 openHABianPi systemd[1]: openhab2.service: Failed with result ‘exit-code’.
Mar 08 11:17:36 openHABianPi systemd[1]: Stopped openHAB 2 - empowering the smart home.

I have given just general information on how to avoid an unstable openHAB.

You have apparently deleted karaf required directories and files and you probably need to copy over files from a fresh openHAB setup.

Thanks again:

I think I got it running again with this:

I did exactly this, without really knowing what it does:
first check current permissions:

ls -al  /var/lib/openhab2/cache /var/lib/openhab2/tmp

and then try:

sudo su
systemctl stop openhab2
mv /var/log/openhab2/openhab.log /var/log/openhab2/openhab.log.old
chown -R openhab:openhab /var/lib/openhab2/cache /var/lib/openhab2/tmp
systemctl start openhab2
tail -f /var/log/openhab2/openhab.log

after that Openhab restarted, I waited a while and did sudo reboot. Then it restarted, and I turned off Putty to see if it keeps running. It did…

How do I know if that really solved it? Do I need to do anything else on the console?

You changed the ownership of the files that OH needs to read and write so that OH can now read and write to them. For some reason they ended up being owned by root instead of openhab.

Is OH running? Do you see errors in openhab.log or the console? Does it appear to work?

It looks like it is working. Thank you for clarification!!

The only thing I didn’t get back to work is zigbee2mqtt by mqtt1 binding. The devices on mqtt2 and set up in paperui are working… but the ones in the item files not. I checked, The zigbee2mqtt service is running and I also see there, that the devices are updating. The broker is also correctly entered.It just doesnt show in openhab logs…

Is the MQTT1 binding installed?

I think that is where the issue is…
MQTT 1 and 2 Binding are installed.

Everything on 2 works.

And in the mqtt.cfg file is also nothing different than it was before. Still I get this here in the logs when I am saving:
2019-03-08 17:15:15.019 [WARN ] [g.dispatch.internal.ConfigDispatcher] - The file /etc/openhab2/services/mqtt.cfg subsequently defines the exclusive PID ‘org.openhab.mqtt’. Overriding existing configuration now.

2019-03-08 17:15:15.048 [ERROR] [org.apache.felix.configadmin ] - Cannot use configuration org.openhab.mqtt for [,, id=483, bundle=235/]: No visibility to configuration bound to mvn:org.openhab.action/org.openhab.action.mqtt/1.13.0

You are not on OH2 snapshots are you? Because mqtt1 and mqtt2 are not compatible on snapshots anymore.

Temporarily or permanently? It might be worth an announcement or something like that if they will not be compatible going forward. I know it will change my plans for when I can move to M2 when it get’s released. I’ve still a few dozen Items I’ve not converted yet.

Temporary only. I have to check the situation for the oh 2.5 release again. At the moment the mqtt2 service has the same service id than the mqtt1 service (because we replaced eclipse.smarthome with openhab).

1 Like

I am on a stable version. I think 2.4.0.

Any other ideas?

I got it fixed by removing turning off the legacy apps, then removing mqtt 1, activating legacy apps, installing mqtt 1 again and all the sudden the zigbee2mqtt updates were received…

Still thank you for all your help!!!

One more odd behaviour is still there also after clearing the cache.

That happened already before the first time I cleaned the cache and my thought is again, that it is maybe the persistence… my other theory is failing batteries (but why all together?) since I cannot see the values (dont ask me why it is not provided).

Yesterday in the middle of the night all my xiaomi window contacts opened one by one. I get for a door or window opening a message by telegram and from 0:26 to 1:06am all 9 sensors opened one after the other. Pretty creapy when your trying to sleep and your mi band vibrates you awake each time…

For an alarm system this is a big no no! I cannot have the sensors be failing when I am not at home and starting the outside siren.

I will move the sensors soon to zigbee2mqtt but right now they are still on the xiaomi bridge and I am not entirely sure if moving them solves the issue.

The log data I didnt check yet, but I am pretty sure it will only say changed from closed to open…

What can I do? Where can I check why that behaviour appears?

Thanks again!!!

I wrote a quick rule, that I can force the windows to be closed by the click of a button (this way I dont need to walk around and open and close all windows manually. But not even 5 min later after overwriting the window status, the contacts started opening again…

2019-03-22 09:12:14.557 [vent.ItemStateChangedEvent] - mihome_sensor_magnet_158d0001c2e75b_isOpen changed from CLOSED to OPEN
2019-03-22 09:12:14.598 [ome.event.ItemCommandEvent] - Item ‘Door_or_Window_Open’ received command ON
2019-03-22 09:12:14.664 [vent.ItemStateChangedEvent] - Door_or_Window_Open changed from OFF to ON
2019-03-22 09:13:17.384 [vent.ItemStateChangedEvent] - mihome_sensor_magnet_158d000201445f_isOpen changed from CLOSED to OPEN
2019-03-22 09:13:17.450 [ome.event.ItemCommandEvent] - Item ‘Door_or_Window_Open’ received command ON

In the XIAOMI Mi Home App the windows stay closed btw. Thought maybe its a battery issue, but I guess its not…

The last time opened values still show when the windows and doors were actually opened. No randomly opening is recorded here… So i can only guess it is an openhab issue.

I am thinking of writing a rule, that checks after receiving an opening if the last time opened value got updated… if not, stay closed. But also not the best solution.