Mqtt binding 2.4 not actually sending messages

Working on moving my mqtt stuff over to the 2.4 mqtt binding. But having some issues with everything appears to work, except it doesn’t actually send anything to mqtt broker.

I have the following in my things

Bridge mqtt:broker:broker1 [ host="192.168.2.17", secure=false ]
{
        Thing topic LivingRoomOutlet1
        {
                Channels:
                        Type switch : switch "Lamp test" [stateTopic = "mygateway1-out/2/1/1/0/0", commandTopic = "mygateway1-in/2/1/1/0/2" ]
        }

        Thing topic BedroomRepeaterNode
        {
                Channels:
                        Type switch : BedroomMotionSensor "Bedroom Motion Sensor" [stateTopic = "mygateway-out/200/1/1/0/16" ]
        }
        Thing topic BedroomLampNode1
        {
                Channels:
                        Type switch : BedroomLightLeft "Bedroom Light Left" [ stateTopic = "mygateway-out/25/1/1/0/0", commandTopic = "mygateway1-in/25/1/1/0/2" ]
                        Type switch : BedroomLightRight "Bedroom Light Right" [ commandTopic = "mygateway1-in/25/2/1/0/2" ]
        }
}

My item I am working on right now is.

Switch BedroomLightLeft "Bedroom Light (left)" <light> (gBedroomLights) { channel = "mqtt:topic:BedroomLampNode1:BedroomLightLeft" }

Then I have my sitemap entry

Switch item=BedroomLightLeft

When I flip the switch i get the following entry in the logs.

==> /var/log/openhab2/events.log <==
2019-01-27 12:46:23.249 [ome.event.ItemCommandEvent] - Item 'BedroomLightLeft' received command ON
2019-01-27 12:46:23.249 [nt.ItemStatePredictedEvent] - BedroomLightLeft predicted to become ON
2019-01-27 12:46:23.251 [vent.ItemStateChangedEvent] - BedroomLightLeft changed from OFF to ON

But there is no message posted to mqtt broker.

I have the old mqtt binding disabled and all have the 2.4 binding installed.

Anyone see something I am obviously missing lol

Thanks!

I have exactly the same problem. Looking for answers …

Add the broker name in the item like below.

Switch BedroomLightLeft "Bedroom Light (left)" <light> (gBedroomLights) { channel = "mqtt:topic:broker1:BedroomLampNode1:BedroomLightLeft" }

EDIT:
Not sure how picky the binding is but also removed the space after the = like below.

Bridge mqtt:broker:broker1 [ host="192.168.2.17", secure=false ]
{
        Thing topic LivingRoomOutlet1
        {
                Channels:
                        Type switch : switch "Lamp test" [stateTopic ="mygateway1-out/2/1/1/0/0", commandTopic ="mygateway1-in/2/1/1/0/2" ]
        }

        Thing topic BedroomRepeaterNode
        {
                Channels:
                        Type switch : BedroomMotionSensor "Bedroom Motion Sensor" [stateTopic ="mygateway-out/200/1/1/0/16" ]
        }
        Thing topic BedroomLampNode1
        {
                Channels:
                        Type switch : BedroomLightLeft "Bedroom Light Left" [ stateTopic ="mygateway-out/25/1/1/0/0", commandTopic ="mygateway1-in/25/1/1/0/2" ]
                        Type switch : BedroomLightRight "Bedroom Light Right" [ commandTopic ="mygateway1-in/25/2/1/0/2" ]
        }
}

ill try that now. Thanks

Hmmm, no change there. I added the broker1 and no change.

FYI There is a bug with the 2.x binding text files that requires OH to restart anytime you make a file change.

oh!! let me try that.

I think you also need to add the port to the bridge. Default is 1883 see example below.

Bridge mqtt:broker:broker1 [ host="192.168.2.17", port=1883, secure=false ]
{

The bindings do not parse those files, the openHAB core does. And it is whitespace agnostic, you can add as many blanks as you want.

That is apparently true at the moment. Unfortunately the main contributor of the MQTT binding (which happens to be me) does not use text files so he doesn’t notice any breakages with text file usage :confused:

Defaults don’t need to be set explicitly :slight_smile: You can as well remove “secure” and “port”.

1 Like

Didn’t seem to be it either. Everything seems to be ok except it just doesn’t send to mqtt.

What’s the easiest way to get the logging for this binding spitting more out?

Ehm… I know that is effort for text users, but could you add a Thing for the configured broker and a Switch via Paper UI and test if it also doesn’t send anything?

Not sure what your mqtt 1.x items were but here’s what I’ve moved over to mqtt 2.x thus far. Maybe you can use this to compare with your items.

Things

Bridge mqtt:broker:pibroker "pibroker" [ host="10.0.1.10", port=1883, secure=false, username="name", password="secret" ]
{
    // Sonoffs
    Thing topic sonoff11 "Living Room Light" @ "Living Room" {
    Channels:
        Type switch : power       "Power"         [ stateTopic="stat/sonoff11/POWER", commandTopic="cmnd/sonoff11/POWER" ]
        Type number : temperature "Temperature"   [ stateTopic="tele/sonoff11/SENSOR", transformationPattern="JSONPATH:$.SI7021.Temperature" ]
        Type number : humidity    "Humidity"      [ stateTopic="tele/sonoff11/SENSOR", transformationPattern="JSONPATH:$.SI7021.Humidity" ]
    }

    Thing topic sonoff2 "Couch Light" @ "Couch Light" {
    Channels:
        Type switch : power        "Power"         [ stateTopic="stat/sonoff2/POWER", commandTopic="cmnd/sonoff2/POWER" ]
    }

    Thing topic sonoff55 "Office Light" @ "Office" {
    Channels:
        Type switch : power        "Power"         [ stateTopic="stat/sonoff55/POWER", commandTopic="cmnd/sonoff55/POWER" ]
    }

    Thing topic sonoff-7CB10D "Front Porch Light" @ "Porch" {
    Channels:
        Type switch : power        "Power"         [ stateTopic="stat/sonoff-7CB10D/POWER", commandTopic="cmnd/sonoff-7CB10D/POWER" ]
    }
}

Items

Switch LivingRoom_Light "Living Room Light" <light>  ["Lighting"] { channel="mqtt:topic:pibroker:sonoff11:power" }
Number LivingRoom_Light_Temp "Temperature [%.1f °F]"      <temp>             { channel="mqtt:topic:pibroker:sonoff11:temperature" }
Number LivingRoom_Light_Humidity    "Humidity [%.1f %%]"    <humidity>       { channel="mqtt:topic:pibroker:sonoff11:humidity" }

Switch CouchLight "Couch Light" <light>  ["Lighting"]  { channel="mqtt:topic:pibroker:sonoff2:power" }

Switch OfficeLight "Office Light" <light>  ["Lighting"]  { channel="mqtt:topic:pibroker:sonoff55:power" }

Switch FrontPorch_Light "Front Porch Lights" <light>  ["Lighting"]  { channel="mqtt:topic:pibroker:sonoff-7CB10D:power" }
	

Hope this helps

No luck on a sensor. My motionsensor is triggering and i can see it on the mqtt broker. But openhab isn’t triggering.

Thing topic BedroomRepeaterNode
        {
                Channels:
                        Type switch : MotionSensor "Bedroom Motion Sensor" [stateTopic = "mygateway1-out/200/1/1/0/16" ]
        }

item

Switch BedroomMotionSensor "Bedroom Motion Sensor" (gMotionSensors) { channel = "mqtt:topic:broker1:BedroomRepeaterNode:MotionSensor" }

but it never triggers.

motion sensor is on and off and nothing.

i gotta be missing something lol

edit: i may be an idiot. i think i found a typo

well. thought i was on to something. but i was wrong. still not doing anything on payload change of stateTopic.

And your thing is online? You can also temporarily subscribe to a more generic state topic for example # to make sure that it is not a typo.

You are using mySensors…

                        Type switch : switch "Lamp test" [stateTopic = "mygateway1-out/2/1/1/0/0", commandTopic = "mygateway1-in/2/1/1/0/2" ]

Shouldn’t it be the other way around?

                        Type switch : switch "Lamp test" [stateTopic = "mygateway1-in/2/1/1/0/0", commandTopic = "mygateway1-out/2/1/1/0/2" ]

I got things working somewhat. Still having some issues. But here is what i have in my things

Thing topic BedroomRepeaterNode
        {
                Channels:
                        Type switch : MotionSensor "Bedroom Motion Sensor" [stateTopic = "mygateway1-out/200/1/1/0/16"  ]
                        Type number : LightNumReadings "Number of Readings to take" [stateTopic="mygateway1-in/200/2/1/0/25" ]
                        Type number : LightSleepTime "Sleep Time" [ stateTopic="mygateway1-in/200/2/1/0/24" ]
                        Type number : LightLevel "Lux Level" [ stateTopic = "mygateway1-out/200/2/1/0/23" ]
        }

then in my items i have.

Number MasterBedRoomLightLevel "Master Bedroom Lux Level [%s]" {channel="mqtt:topic:broker1:BedroomRepeaterNode:LightLevel"}
Switch MasterBedroom_MotionSensorOverride "Motion Override [%s]" (gOverrides)
Switch BedroomMotionSensor "Bedroom Motion Sensor" (gMotionSensors) { channel = "mqtt:topic:broker1:BedroomRepeaterNode:MotionSensor"  }

It’s working. I still have work to do. But it’s slowly coming along.