Mqtt 2.4 binding question

Here is my question, does the broker connection need to be in the same file as the bridge? I seem to have had some instability moving the broker connection out? Also, does it hurt to have multiple connections to the same mqtt broker?

This is the line in question from below: “mqtt:broker:TreasureBox “TreasureBox (Mosquitto)” [ host=“192.168.1.200”,secure=false, username=“user”, password=“pass” ]” Can it be in a separate file? I was trying to group my sonoff things together.


mqtt:broker:TreasureBox "TreasureBox (Mosquitto)" [ host="192.168.1.200",secure=false, username="user", password="pass" ]
Bridge mqtt:broker:TreasureBox 
{         
    Thing topic HolidaySwitch1 "Holiday Switch 1(Sonoff Basic)" {
    Channels:
        Type switch : Power "Holiday Switch 1 Power" [ stateTopic="stat/sonoff/holidayswitch1/POWER", commandTopic="cmnd/sonoff/holidayswitch1/POWER" ]
        //Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
        //Type string : alarmpanel "Alarm system" [ stateTopic="alarm/panel/state", commandTopic="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
        //Type color : lampcolor "Kitchen Lamp color" [ stateTopic="lamp/color", commandTopic="lamp/color/set", rgb=true ]
        //Type dimmer : blind "Blind" [ stateTopic="blind/state", commandTopic="blind/set", min=0, max=5, step=1 ]
    }
	
	Thing topic AutoPlug "AutoPlug" {
    Channels:
        Type switch : Power "AutoPlug Power" [ stateTopic="stat/sonoff/autoplug/POWER", commandTopic="cmnd/sonoff/autoplug/POWER" ]
        //Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
        //Type string : alarmpanel "Alarm system" [ stateTopic="alarm/panel/state", commandTopic="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
        //Type color : lampcolor "Kitchen Lamp color" [ stateTopic="lamp/color", commandTopic="lamp/color/set", rgb=true ]
        //Type dimmer : blind "Blind" [ stateTopic="blind/state", commandTopic="blind/set", min=0, max=5, step=1 ]
    }
}


Never tried it myself but it was reported to be working from separate files.
What kind of instability so you observe?

Same as @opus. Not tried it but apparently it was a work around for the disconnecting bug in 2.4

No, you can define as many broker things as you want.

@vzorglub thanks for info.

@opus I was having what could be described as disconnecting but only on a restart.

I am going to spend a few mins tonight and see if I can put a quick process together that breaks it. In short it seems as if I setup the mqtt in one file all is well and I can stop start openhab with no issues. When I split the broker to a separate file it appears that all works until I restart openhab.

I am going to spend more time the next couple days then post results. If there is a problem in the binding I have no issue posting an issue. Just don’t want to post if the problem is misuse.

To circumvent misuse the next time, your report can also in that case be very helpful to improve the binding documentation.

@David_Graeff this is true! I did have an issue with a documentation mismatch. I will get all my findings together over the next few days and post something.

One document showed a parameter with : in between fields and the other binding doc showed spaces. Spaces seemed to work. I found it simple enough to try both ways, but probably could be updated.

1 Like