MQTTv2 requires restart of openhab to add new topics

On OH 2.5.x and mqtt binding 2.6 (with my own broker), I have my MQTT topics in a Things file and when I add new topics the binding does not seem to pick them up right away until I restart openhab.

For example if I add this as a new block:

   Thing topic gmc600 "GMC600" {
   Channels:
           Type number : CPM [ stateTopic="sensors/radCPM" ]
           Type number : uSv [ stateTopic="sensors/raduSv" ]
   }

I won’t see any item updating that is using the channel until I restart openhab. Restarting the binding itself with openhab-cli didn’t seem to help, but I’m not sure I restarted the right one and in the right sequence.

It’s probably pilot error on my part since it’s been going on for a long time and I just restart, but I can’t seem to figure out what the problem is.

I had this with openHAB 2.5.4, but not anything later. It’s a known bug in older versions. I’m not certain that’s it’s specific to the MQTT binding?

However, to force openHAB to read your things file, I usually:

  1. Add nonsense to the Things file (some poor syntax, or remove a { or ) from somewhere).
  2. Save the now corrupted Things file.
  3. openHAB will complain, and unload all the Things from that file.
  4. Fix the file, and resave.
  5. openHAB will load all the things from the file back in.

Restarting the specific bundle(s) via the Karaf console should do the same.

But the OP said that didn’t work (with caveats), and I think that’s because it was an openHAB problem, not a binding problem.

For me, though, it’s always faster to remove and re-add something to a file which I’m already working on, than it is to restart a bundle from the console. YMMV

Sorry, I missed that one.
However, stating bundle(s) was on purpose, because the MQTT binding does install more then one, so the OP might have missed the correct one (as he stated as well).

1 Like

Note that you are talking Items, and this complaint is as likely on the face of it to be about not properly forming the link as the channel/Thing.

PaperUI should give a view of “what the system thinks” about the shape of a Thing etc.
“What the binding thinks” could be different - if you edit a topic for example, the binding has to spot that, unsubscribe the old topic, subscribe a new one.
It would be interesting to pin down where the remaining issues lie.

Thanks for the comments. Yes I mean the linkage between the thing and the item such that the item does not receive any update. Often I re-arrange and rename things, and I believe sometimes depending on what I do it can cause it to break the link.
I’ll do a bit more testing and try to narrow down the actual ways it can require a restart. It certainly doesn’t require it in all cases.
I’ve been restarting org.openhab.binding.mqtt and org.openhab.binding.mqtt.generic. There are six of them so maybe I’ll try more or a different order …