Mqtt and openhab item file reload

Hi everybody

Does someone had any experience when I change my ITEM file and it gets reloaded, all my mqtt items in the file does not work anymore. Really strange…To correct that, I have to reboot the item device (switch with esp8266) and have it reconnect…
I also test MQTT Spy to see if the brooker is still up and it IS. So…what I’m doing wrong?


When you change item files in openHAB, openHAB “forgets” the items’ states until bindings post new updates for them. In the case of MQTT, there won’t be updates until whatever publishes to those MQTT topics publishes again, OR if they were published earlier with the MQTT retain flag set.

So one possible improvement is to have your ESP8266 publish values with the retain flag set, so the broker remembers the last published messages, and any subscribers will be immediately informed upon subscribing.


Thanks for your help.
I changed the code so that que retain flag is set to 1 in mqtt (lwt and
publish), including openhab config retain=true, and it does not work.When I
start system ou change item files (which I dont know if is the same) the
value are lost (Uninitialized state). The only way that I have found is to
republish the message from esp8266 (nodemcu). Do you know anyway to improve

Thanks for your help

2016-01-24 23:23 GMT-05:00 watou

I believe that setting only applies when you are publishing to the broker, not subscribing.

In my setup, my MQTT publishers publish with the retain flag set, so when the MQTT bindings subscribe, all values previously published with the retain flag set are sent over to the new subscriptions. So I don’t know why it doesn’t work for you…

An alternative could be to use a persistence service in openHAB, and use the restoreOnStartup strategy. Other than that, I’m out of ideas, other than to increase the frequency of the publishes so the items are Uninitialized for a shorter time.


I managed to develop a refresh string into esp8266. So when i refresh item
file,i have a rule that checks the state of the item and if it is at a
unintialized state, it triggers a refresh mqtt on the item. It works.

Le 2016-01-25 18:08, “watou” a écrit :

I have exactly the same problem.
Has anyone found a solution?