MQTT connection

Hello,

I cant make the MQTT to run.

I am publishing on this topic:
test/evt/status
and my test.items has the following:
String node1_temp “Temp [%s °C]” (node1,all) {mqtt="<[mysensor:test/evt/status:state:default]"}

my configuration filas has the following configuration:
mqtt:mysensor.url=tcp://192.168.1.4:1883
mqtt:mysensor.clientId=MQTT

but when I open the URL, there’s nothing being shown. I just see a -ºC on the Temp field.

checking the broker connections with the netstat -an,
I can see an active connection on the server IP/PORT.

Why cant I see the values displayed on the server?
Am I doing something wrong with the MQTT string?

Thanks

If the message you publish to the broker is a proper number, the MQTT binding in openHAB 1.7* will parse it as a DecimalType number, which String items won’t accept. With that version of the MQTT binding, you are forced to use a Number item for the state update to work properly.

Number node1_temp "Temp [%.1f °C]" (node1,all) {mqtt="<[mysensor:test/evt/status:state:default]"}

Number items make more sense if you are sure the MQTT messages on the topic will always be properly formatted numbers, since you can more easily handle the number in the UI, rules and persistence.

If, however, you really do want to use a String item, you can replace the MQTT binding JAR with the one that will be part of openHAB 1.8, which you can find here. The newer version of the binding JAR will allow the use of String items for any subscribed message.

1 Like

Thanks for your reply.

I’ve tried with your suggested configuration but still doesn’t work.
I can see the client connected to the broker.

(netstat -an) shows the connected clients

I also have a client (MQTT Client Chrome extension) where I can publish in a certain topic.

Publishing here:
evt/status/fmt

and the string for the openhab is:
Number node1_temp “Temp [%.1f °C]” (node1,all) {mqtt="<[mysensor:evt/status/fmt:state:default]"}

Still cant see nothing when opening the browser

Thanks again for your help.