MQTT 2.5 Binding - stops working all by itself

Folks,

I recently converted everything from mqtt 1.x to 2.5 and my smart home is now dumber than a mud hut. :slight_smile:

**Details
2.5.11 running docker on rpi4, only container running.
mosquito running docker on another rpi4

tldr;

  • Things, with brokers, subscribed
  • items linked to the channels

things

Bridge mqtt:broker:LEDBroker [ host="mqtt.home", secure=false, port=1883]
{
Thing topic RoomsKitchenCupboard1
    {
        Channels:
            Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set" ]
            Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness/set", min=0, max=255 ]
            Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0/set" ]
    }
}

items:

Switch	kitchen_led_cupboard1_switch    "Kitchen Cupboard 1 Switch"     (g_Kitchen_switch)                                                                      {channel="mqtt:topic:LEDBroker:RoomsKitchenCupboard1:SwitchState"}      //{ mqxtt=">[mqtt:home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set:command:ON:1],>[mqtt:home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set:command:OFF:0]" }
Color 	kitchen_led_cupboard1_color     "Kitchen Cupboard 1 Color"      (g_KitchenCupboards_Colour)                                                             {channel="mqtt:topic:LEDBroker:RoomsKitchenCupboard1:color"}            //{ mqxtt=">[mqtt:home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/set:command:*:default]" }	
Dimmer 	kitchen_led_cupboard1_dimmer    "Kitchen Cupboard 1 Dimmer"     (g_Kitchen_Brightness, g_KitchenCupboards_Brightness, g_Kitchen_Brightness_AutoDim)     {channel="mqtt:topic:LEDBroker:RoomsKitchenCupboard1:dimmer"}           //{ mqxtt=">[mqtt:home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness/set:command:*:JS(convert.js)]" }

First I force the message in mqtt to 0:

I set the item to 10
image

log:tail:

events.log

2020-12-19 16:09:06.831 [ome.event.ItemCommandEvent] - Item 'UtilityElectricKWH10m' received command 2.09400000
2020-12-19 16:09:06.834 [vent.ItemStateChangedEvent] - UtilityElectricUnitsTotal changed from 986.909 to 986.910
2020-12-19 16:09:07.071 [ome.event.ItemCommandEvent] - Item 'kitchen_led_cupboard1_dimmer' received command 10
2020-12-19 16:09:07.075 [nt.ItemStatePredictedEvent] - kitchen_led_cupboard1_dimmer predicted to become 10
2020-12-19 16:09:08.438 [vent.ItemStateChangedEvent] - UtilityElectricPulse changed from OFF to ON
2020-12-19 16:09:08.471 [ome.event.ItemCommandEvent] - Item 'UtilityElectricPulse' received command OFF

Now having a look at mqttspy, the message is still

To solve all this, I can comment out the thing watch it unsubscribe, put it back in, and watch it subscribe, and it works. At some random point over the day/week, this will break.

Commented out:

Now removed.

Put it back and save:

Update the item:
image

Message:

Now mqttspy shows the value (note that 0-100 is scaled 0-255)

This happens across all the different items. Sometimes it’s ok for a while, sometimes it breaks quickly. It does not affect all items in the same broker (I have 10 brokers with over a hundred items)

Is there anything else I can do/check with this as it’s rendered everything useless?

TIA

C

This sounds mad! Do you mean you’ve defined 10 brokers within openHAB? I think the idea is that you define a single Broker Thing, and all your device Things communicate through that Bridge Thing.

I have split the definition of the Broker Thing into a separate file, so that I don’t need one long file for all my MQTT things. See the example in the hidden documentation:

Why would that be mad?

I’ve got 10 files, one broker (or is that bridge) per file (split logically by function) multiple things (one per, well, thing :smile:) and multiple channels per thing.

Originally had one file but had these problems so thought splitting it would be better. Problems still persist.

I only have one bridge to rule them all.

You can still have multiple files you just need to create your things a little different. Eg your thing in a different file would become

Thing mqtt:topic:RoomsKitchenCupboard1 "Kitchen Cupboard ONE Label" (mqtt:broker:LEDBroker)  {
       Channels:
           Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set" ]
           Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness/set", min=0, max=255 ]
           Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0/set" ]
   }

Or in mainUI

UID: mqtt:topic:myMQTTBroker:RoomsKitchenCupboard1
label: Kitchen Cupboard ONE Label
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:LEDBroker
channels:
  - id: SwitchState
    channelTypeUID: mqtt:switch
    label: Switch
    description: ""
    configuration:
      commandTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set
      stateTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0
      off: OFF
      on: ON
  - id: dimmer
    channelTypeUID: mqtt:dimmer
    label: Dimmer
    description: null
    configuration:
      commandTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness/set
      min: 0
      stateTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness
      max: 255
  - id: color
    channelTypeUID: mqtt:color
    label: Color
    description: null
    configuration:
      commandTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0/set
      stateTopic: home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0

Are you using ten different servers or did you configure the same sever on all things?

As said

And as @denominator says

So, just have a separate file with your Broker Thing. Keep all your other Things files but remove the bridge from them, and modify the syntax to match those in the linked documentation, or from @denominator post.

Interesting. I did not know you could write it that way. will convert some and see.

Nope, same server. Issue is consistent across all things. Server though is the same one, container, host, as when I was using the 1.x binding. Didn’t miss a beat.

Will try it.

Thinking about this though; I might be wrong but I am sure that the problem is always on the publish side - not subscribe.
I have lots of sensors, custom-built, sonoff, zigbeetomqtt etc which all work perfectly. It’s only when OH is trying to publish.

I’m currently looking at the logs on mosquitto to see if there is something there.

I doubt that multiple connections to the same server are supported. Use one broker per server. If the problem persists, report back with full logs.

I thought multiple, unique named connections are. It works, just not very reliable.

Nonetheless, I’ve now migrated all over and same issue exists. :frowning:

no messages received by mqttspy

Nothing there on that topic.

Cfig now:
Items:

Dimmer 	bathroomroom_led_basin_dimmer 	"Bathroom basin LED Brightness" (g_persist_restore, g_BathroomLEDDimmer, g_Bathroom_Dimmer,g_persist_change)    {channel="mqtt:topic:mqtt:BathroomBasin:dimmer"}

things:

mqtt.bridges.things

// Bridge mqtt:broker:LEDBroker [ host="mqtt.home", secure=false, port=1883]
Bridge mqtt:broker:mqtt      [ host="mqtt.home", secure=false, port=1883]
// Bridge mqtt:broker:utilityBroker [ host="mqtt.home", secure=false, clientID="OH-Utility"]//, username="", password="" ]
// Bridge mqtt:broker:zigbeeBroker [ host="mqtt.home", secure=false]

// Bridge mqtt:broker:tasmotaPlugsBroker [ host="mqtt.home", secure=false, port=1883]
// Bridge mqtt:broker:sonoffBroker [ host="mqtt.home", secure=false, port=1883]

// Bridge mqtt:broker:sonoffPowerBroker [ host="mqtt.home", secure=false, port=1883]

// Bridge mqtt:broker:monitor [ host="mqtt.home", secure=false, port=1883]
// Bridge mqtt:broker:blindsBroker [ host="mqtt.home", secure=false, port=1883]

mqtt.LED.things


Thing mqtt:topic:WetroomBasin "Wetroom basin" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/relay/0",      commandTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/brightness",   commandTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/brightness/set" , min=0, max=255]
        Type color      : color         "Colour"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/hsv/0",        commandTopic = "home/lights/wetroom/led/LED_WETROOM_BASIN/hsv/0/set" ]
}

Thing mqtt:topic:WetroomShower "Wetroom Shower" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/relay/0",      commandTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/brightness",   commandTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/brightness/set" , min=0, max=255]
        Type color      : color         "Colour"           [stateTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/hsv/0",        commandTopic = "home/lights/wetroom/led/LED_WETROOM_SHOWER/hsv/0/set" ]
}



Thing mqtt:topic:BathroomBasin "BathroomBasin" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"    [stateTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/relay/0",        commandTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"    [stateTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/brightness",     commandTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"    [stateTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/hsv",            commandTopic = "home/lights/bathroom/led/LED_BATHROOM_BASIN/hsv/set" ]
}

Thing mqtt:topic:RoomsBackRoomLantern "RoomsBackRoomLantern" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/relay/0",       commandTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/brightness",    commandTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/brightness/set", min=0, max=255]
        Type color      : color         "Colour"           [stateTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/hsv/0",         commandTopic = "home/lights/backroom/LED_BACKROOM_LANTERN/hsv/0/set" ]
}

Thing mqtt:topic:RoomsKitchenLantern "RoomsKitchenLantern" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_LANTERN/hsv/0/set" ]
}
Thing mqtt:topic:RoomsKitchenCupboard1 "RoomsKitchenCupboard1" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_1/hsv/0/set" ]
}

Thing mqtt:topic:RoomsKitchenCupboard2 "RoomsKitchenCupboard2" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_2/hsv/0/set" ]
}

Thing mqtt:topic:RoomsKitchenCupboard3 "RoomsKitchenCupboard3" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/relay/0",      commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/relay/0/set" ]
        Type dimmer     : dimmer        "Dimmer"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/brightness",   commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"           [stateTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/hsv/0",        commandTopic = "home/lights/kitchen/led/cupboard/LED_KITCHEN_CUPBOARD_3/hsv/0/set" ]
}


Thing mqtt:topic:RoomsBackRoomTVLED "RoomsBackRoomTVLED" ( mqtt:broker:mqtt) 
{
    Channels:
        Type switch     : SwitchState   "Switch"           [stateTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/relay/0",                     commandTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/relay/0/set" ]
        Type dimmer     : dimmer        "Switch"           [stateTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/brightness",                  commandTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/brightness/set", min=0, max=255 ]
        Type color      : color         "Colour"           [stateTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/hsv",                         commandTopic = "home/lights/backroom/tv/LED-BACKROOM-TV/hsv/set" ]
}

And after I comment it out and put it back again - it works:

So a patter is/could be:
Add things, they work. Add a new thing, it works but others that were added may/may-not work.
Refresh the not-working, and that now works.

C

I’ve since noticed that I had my items connected incorrectly.

I had

Switch  FrontRoom_sw_Dining_chk             "Front Room - Dining - Check"       <wallswitch> 	(g_persist_restore, g_CheckSwitch, g_persist_change)  {channel="mqtt:topic:checksBroker:RoomsFrontRoomDiningCHK:SwitchState"}

whereas I now have:

Switch  FrontRoom_sw_Main_chk               "Front Room - Lounge - Check"       <wallswitch>    (g_persist_change, g_CheckSwitch)                       {channel="mqtt:topic:RoomsFrontRoomLoungeCHK:SwitchState"}

Notice the channel had the broker in. That worked so not “totally” wrong.
But with the new thing syntax, it does not work. The second one is how they are now.

Sorry I suppose I should have pointed out the change in the channel.

Sometime the things files don’t get loaded correctly, sometime I just add a line at the bottom and resave and they work.

Sorry, I’m willing to fix problems in the binding, but as long as you use textual configuration with all the possibilities of doing things wrong, I’m not able to help you.

1 Like

I agree that the text option has more chances of getting things wrong but I don’t think that’s happening here. The point is they work and then they stop working. Up until 3.0, I thought most people used text for config?

I will though migrate a few items to the GUI and see if they hit the same problem. With 271 items using mqtt it would be a small chance we’d hit a case. But will try.

It’s clearly not a more common problem as more people would be talking about it but it is a problem and is an issue for me since moving over from 1.x to 2.x.

Since making all the changes last night, I cannot see any that have stopped working so perhaps the one bridge is better. Will continue monitoring.