Hi guys,
It’s a general thing about the OpenHAB 2 system. I use it on an ubuntu virtual machine on multiple Raspberry Pi’s so it’s always the same.
If you have caching problems you could do following for restarting the MQTT-Broker:
sudo systemctl stop mosquitto.service
# Delete the mosquitto.db containing all the stored message data in the persistence. By default, located in /var/lib/mosquitto/mosquitto.db
sudo rm /var/lib/mosquitto/mosquitto.db
# Restart the mosquitto service
sudo systemctl start mosquitto.service
sudo systemctl restart mosquitto.service
And following for restarting OH:
sudo systemctl stop openhab2.service
# if openhabian is installed
sudo openhab-cli clean-cache
# if openhabian is not installed
sudo rm -rf /var/lib/openhab2/cache/*
sudo rm -rf /var/lib/openhab2/tmp/*
sudo systemctl start openhab2.service
Well, i think it’s not really new for you. But that’s of course not the point I want to discuss.
Most of you will find out that this does not work reliably. Sometimes you will miss the sitemaps and sometimes you will miss the items and so on. It sucks. The solution is to restart the openhab2.service
again and again and again and again.
It would be nice if there was a way to determine via bash script if the items, sitemaps etc. could be loaded. If not, then you repeat the restart until everything could be loaded. So a bash script that cleans the cache would be very helpful.
I have currently solved it by restarting all my OpenHAB systems and then adding a delay of 15 seconds and restarting one more time. In most cases, it seems that two restarts are needed to fix the caching problem.
Would be happy if there are good suggestions here on how to solve this more elegantly and reliably.
If I address not only OpenHAB but also MQTT, then from experience that there the cache can also be full. Therefore I give another useful tip: If the cache should be full, also sometimes changes are not taken over. Say in /etc/openhab2/services/mqtt-eventbus.config the configuration may be correct, but a change in /var/lib/openhab2/config/org/openhab/mqtt-eventbus.config was not saved. As a result, the MQTT configuration is no longer correct. There may be commandPublishTopic="", commandSubscribeTopic="" or statePublishTopic="" or stateSubscribeTopic="" or other errors that would lead to an infinite loop because. This would fill the cache over and over again, not only slowing the system down insanely and making it barely debuggable. One must first find that then conifugarion changes were not effective. A frequent restart then also brings nothing more.
Back to topic: A more reliable solution could be helpful. Thanks in advance.