Binding-mqtt - 2.4.0 not working

  • Platform information:
    • Hardware: RP4

    • OS: raspbian-buster-lite

    • Java Runtime Environment: openjdk version “1.8.0_152”
      OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
      OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)

    • openHAB version: 2.4

  • Issue of the topic: binding-mqtt - 2.4.0 not working
    mqtt binding stops working after modifying .items or .things files
    I need to disable and enable the mqtt:broker binding from karaf console

livingroom.things

Bridge mqtt:broker:rSmartHome "rSmartHome MQTT" @ "Home" [ host="192.168.2.101", port="1883", secure=false ] {
	Thing topic livingroom "Living Room" @ "Home" {
		Channels:
			Type switch : SM10BTN0 "Ceiling Fan" [ stateTopic="home/rfm_gw/nb/node010/BTN0", commandTopic="home/rfm_gw/sb/node010/BTN0", on="1", off="0", postCommand=true, autoupdate=false]
			Type switch : SM10BTN1 "Ceiling Light" [ stateTopic="home/rfm_gw/nb/node010/BTN1", commandTopic="home/rfm_gw/sb/node010/BTN1", on="1", off="0", postCommand=true, autoupdate=false]
	}
}

livingroom.items

Switch SM10BTN0 "Ceiling Fan" {channel="mqtt:topic:rSmartHome:livingroom:SM10BTN0"}
Switch SM10BTN1 "Ceiling Light" {channel="mqtt:topic:rSmartHome:livingroom:SM10BTN1"}
2 Likes

I think this is a known problem, with the MQTT-Binding 2.xx when changing values. So maybe @David_Graeff can help ?

This was a bug in 2.4. with text config files where OH has to be restarted
This was fixed from 2.5M1

Sure ? I observed it in my own SetUp (2.5.M3) when changing the topics Parameter (state/command).

quite sure, I have had this issue back then on 2.4 as well, switched to 2.5M1 solved it.
On M3 all is working as well on my setup

.things look like that:

    Thing topic RPI2 "Raspberry Office  " @ "MQTT2" {
    Channels:
        Type number : temp        "CPU Temp.Office-RPi"  [ stateTopic="/rpi/temp/RPI2_Temp/status"]
    }

PaperUI shows:
grafik

Changing .things StateTopic

    Thing topic RPI2 "Raspberry Office  " @ "MQTT2" {
    Channels:
        Type number : temp        "CPU Temp.Office-RPi"  [ stateTopic="/rpi/temp/RPI2_Temp/test"]
    }

PaperUI still shows:
grafik
:thinking:

have you tried to have it completely in files?
I did have some issues with paperui defined things back then… so i’m avoiding paperui where i can :wink:

I am completely the opposite, just as @rlkoshak all my things are defines by PaperUI. This way, no syntax errors and mostly auto detected. I started with text files and migrated to PaperUI.

I don’t have this issue in PaperUI

Same for me. I mostly use Text-Files, where possible. Even in this case(see Example above). But you can see in PaperUI how your Thing is stored in JsonDB. But after a change in the Text-File the JsonDB seems not to be updated. So I first have to restart OH, and then I see the changes made in the text-file.

But if your Broker is not working you should see it in PaperUI

Do you see any information in the logger ?

do you see anything else in openhab.log when you save your thing file other than this?

2019-09-27 13:27:01.445 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'garden.things'

as this is indicating OH acknowledged changed file and using it

Yes, you mean this:

2019-09-27 09:11:28.893 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt2.things'
2019-09-27 09:12:52.321 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt2.things'
2019-09-27 09:18:46.612 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt2.things'
2019-09-27 09:23:58.589 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt2.things'

That’s from my tests this morning :wink:

Text file defined Things never get stored in JSONDB. They are completely different paths. If you have the Thing in both places, then you have the Things defined twice. I’m not sure what happens in this case but it’s not good. In a best case scenario, the .things file definition will take precedence. But you should not have the same Thing defined both ways. Pick one or the other.

Sorry for my amateurish attempt to explain what happened :pensive: (in my thinking). I always thought that the Text-Files where loaded into JsonDB. Ash over my main for this.
What I meant is that when creating a Thing one can see the result in PaperUI as shown above, is this correct ?
If I now change the command topic in my text-file (and save it) I still see the old value in the PaperUI(Thing). And of course my channel will react only on the old topic!
So if I now restart OH the Thing is newly loaded and now the stateTopic has the value which changed before in the text-file.
Hope this is better understandable what I meant.

BTW:So now it would be interesting for me where the text-files are stored or loaded ?

Thx in advance.
Cheers,
Peter

Yes. PaperUI shows what is in memory and both the .things files and JSONDB feed into memory.

In RAM. The difference is how they are loaded from disk into memory. That whole path is completely separate in the two approaches.

In openhab.log, do you see a line that it’s loading your .things file when you change it?

Yes.

Maybe a bundle restart could help :thinking: ?! (Instead of OH restart) I didn’t try until now. And which one to restart ???

openhab> bundle:list | grep -i mqtt
227 x Active x  80 x 1.2.1                 x Paho MQTT Client
235 x Active x  80 x 2.5.0.M3              x openHAB Add-ons :: Bundles :: MQTT Broker Binding
236 x Active x  81 x 2.5.0.M3              x openHAB Add-ons :: Bundles :: MQTT Things and Channels
237 x Active x  82 x 2.5.0.M3              x openHAB Add-ons :: Bundles :: MQTT HomeAssistant Convention
238 x Active x  82 x 2.5.0.M3              x openHAB Add-ons :: Bundles :: MQTT Homie Convention
245 x Active x  80 x 2.5.0.M3              x openHAB Core :: Bundles :: MQTT Transport
openhab>

Number 236 (in my case). Sorry for my silly questions :pensive:

Got any Items linked to the Thing(s) in question? Many bindings are lazy about updating anything that is not actually in use.

Hi Rossko,
if you mean that the item in question is not often in use, I have to say NO. It’s a new one, which gets every minute a response via Mosquitto.

I have another RPi, which I can use for Office-Applications (Libre-Office,i.e.) with Standard GUI from the RasPi-Project (Just for Fun). This RPI sends the CPU-Temperature to my OH-RPI every Minute via MQTT-Client. Another point is that my Sonoffs (about 15 -20 pieces) always are communicating via Bridge/Thing between Device(s) and OH. Minimum Channels for the devices are 4 Channels. So I think there is a lot of communication. So no time to become lazy for my PI’s.