First step on MQTT and openhab

Hi everybody,

I am quite new in the openhab community. Only a few days since I have discovered openhab. First I want to use openhab to see an 1-wire network of temperature sensors that I read now with a Beaglebone ( white ) over a python script and mqtt . I have installed openhab and mosquitto on a Centos 7 computer

in openhab config

mqtt:mymosquitto.url=tcp://localhost:1883
mqtt:mymosquitto.clientId=openhab

my default.items file looks like:

Group All
Group gGroundFloor (All)

Group GF_Living ā€œLiving Roomā€ (gGroundFloor)

Number MyFirstSensor ā€œTemperature [%.1f C]ā€ (GF_Living) {mqtt="<[mymosquitto:home/temperature:state:default]"}

my default.sitemap

sitemap default label=ā€œMain Menuā€
{
Frame label=ā€œMy First Sensorā€ {
Text item=MyFirstSensor
}
}

in addons folder I have

[root@smallnas addons]# ls -al
total 12
drwxr-xr-x. 2 root root 46 Feb 29 17:53 .
drwxr-xr-x. 14 root root 4096 Feb 29 17:52 ā€¦
-rw-rā€“r--. 1 root root 7590 Feb 1 11:02 org.openhab.action.mqtt-1.8.1.jar

after starting openhab i have in the messages that is subscriberd to mymosquitt mqtt broker .

I am trying now to test :

[root@smallnas ~]# mosquitto_pub -d -t home/temperature -m 20.12
Client mosqpub/7973-smallnas.p sending CONNECT
Client mosqpub/7973-smallnas.p received CONNACK
Client mosqpub/7973-smallnas.p sending PUBLISH (d0, q0, r0, m1, ā€˜home/temperatureā€™, ā€¦ (5 bytes))
Client mosqpub/7973-smallnas.p sending DISCONNECT

or
[root@smallnas ~]# mosquitto_pub -d -t mymosquitto:home/temperature -m 20.12
Client mosqpub/8318-smallnas.p sending CONNECT
Client mosqpub/8318-smallnas.p received CONNACK
Client mosqpub/8318-smallnas.p sending PUBLISH (d0, q0, r0, m1, ā€˜mymosquitto:home/temperatureā€™, ā€¦ (5 bytes))
Client mosqpub/8318-smallnas.p sending DISCONNECT

but any value is indicated in openhab UI

If I subscribe in a topic home/temperature

[root@smallnas addons]# mosquitto_sub -d -t home/temperature
Client mosqsub/8749-smallnas.p sending CONNECT
Client mosqsub/8749-smallnas.p received CONNACK
Client mosqsub/8749-smallnas.p sending SUBSCRIBE (Mid: 1, Topic: home/temperature, QoS: 0)
Client mosqsub/8749-smallnas.p received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/8749-smallnas.p received PUBLISH (d0, q0, r0, m0, ā€˜home/temperatureā€™, ā€¦ (5 bytes))
20.12

Where I am wrong ?

Thank you

You need the binding JAR!

The action JAR provides a publish method to call from rules and scripts, but thatā€™s only useful in the case where you canā€™t or donā€™t want to use an item with an MQTT ā€œout bindingā€ string.

Thank you very much ! Working now , I was looking for mqtt in the name and take the first .jar. Without your message I was looking forever :wink:

1 Like