Web view doesn't reflect states of the switches

I’m using MQTT to communicate between openHAB (1.8.3 on Windows 10) and my home automation system.
All is working fine, except for one thing:

When I open the openHAB web page (or the openHAB app on my smartphone running Android), the actual state of the installation is not reflected correctly. That is, suppose I switched on a light through the web app before I closed the web or android app and I open the web or android app again, chances are that the switch(es) representing the ON or OFF state of the light is/are not in sync with the real situation.

I know there’s a possibility with MQTT that the broker is sending the last known states to the newly connecting clients (which is the case I assume when opening the web page or the app on the smartphone), but I have no clue as to how openHAB registers itself to the broker when activating the web or app. It might be an openHAB configuration, but I couldn’t figure it out yet…

How can I make sure the MQTT broker is sending the last state of the switch(es) to openHAB when I open the web browser or the app on the smartphone?

The events.log file will tell you the last state of items in OH. This should match what you see in the gui. I haven’t seen any problems after upgrading from 1.8.2, which did have bugs in this area.

I can’t tell you where events.log is found on a windows installation though.

Sorry, misinformed you. I’m running the web browser on Windows 10, but openHAB itself is running on a Raspberry Pi 2B.

I will look for the `events.log file on the RPi and see if I can figure out some stuff.

In the mean time, I also tried by setting qos to 1 and retain to true in the openhab.cfg file and then do an openHAB restart, but that doesn’t seem to cure…

The usual place is /var/log/openhab on the pi.


Yes, if you do an sudo apt-get install openhab (or something like this), you’ll find the log file in the directory you specified. But I’ve taken the openHAB zip files directly from the openHAB website and installed them into /home/pi/openHAB. In that case, the events.log file is located in /home/pi/openHAB/logs (just give this info, in case someone else on this forum here is looking after that file too in a similar situation…).

But you gave me a good pointer to look for. When I restart openHAB, then I see both at the end of the stdout feedback as well as in the events.log file the “update” of the broker (mosquitto, running on my Raspberry Pi) towards the client (Firefox on my Windows 10 PC) of the items that are used in the .sitemap file (I have more items prepared into my .items file, but don’t use them yet in the .sitemap file). So, all looks good now.

I think I missed the execution of the part where I modified the retain flag in the openhab.cfg. In a previous answer I said that it didn’t cure my problem, but I was apparently wrong with that conclusion. On the contrary, I do think (I’m almost sure now) that adding the retain part is solving my issue. Maybe there’s no need to change the qos parameter (which I also did, I put it to 1), but I’ll figure that one out at a later moment.

Thanks again!