Mosquitto MQTT Switch

Hello !

im tying to make a MQTT Switch.

my MQTT.sitemap looks like this:


sitemap MQTT label="mqtt" { Frame label="MQTT" { Switch item=mqttsw1 label="MQTT Switch 1" }

the Items File:


Switch mqttsw1 {mqtt=">[mosquitto:/home:command:ON:1],>[mosquitto:/home:command:OFF:0]"}

The openhab.cfg:



with the IP adress of my pi where Mosquitto is installed

With MQTT.fx I’m tying to see my messages “0” and “1” but nothing is there.

Neither on the /home feed or “#”.

When i use mosqitto_sub / mosquitto_pup i can see my MQTT Messages in MQTT.fx.

Got the MQTT binding in the addons folder.

Where is my mistake ?

openHAB version 1.8.1

Mosquitto v3.1

Raspberry Pi 2 Model B

THX for Help & sorry for my bad written english.

Did you install the MQTT binding JAR, not the action JAR?

yes got the “org.openhab.binding.mqtt-1.8.1.jar” in the addons folder.

is it enough to just have it there or do i need to do something with it ?

Is mosquitto set to listen for connections on that interface,, or is it just listening on (or localhost)?

thx for your fast anwers.

mosquitto is running on my Pi. And I can communicate with mosquitto over MQTT.fx with my laptop while using in the mqtt.fx setup.

maybe i dont understand your question. where can i check to give you an answer ?

So your openHAB configuration is intending to send 1 when the switch is turned on, and 0 when it’s turned off, and no subscribers are seeing those messages when you change the switch in the UI?

If you know that a client is reaching the broker on a different system via, then there’s no need to check that. Is /etc/mosquitto/mosquitto.conf or a .conf file in /etc/mosquitto/conf.d set to listen for plain TCP connections on any other ports?

Another avenue is to enable DEBUG logging for the binding and looking in /var/log/openhab/openhab.log. Add the line:

<logger name="org.openhab.binding.mqtt" level="DEBUG" additivity="false">

to logback.xml.

yes im intending to make a relay module.
but from openhab there are no messages on the mosqitto server.

i edited the config file of mosqitto & added:


Port 1883 should be used anyway.

still no connection between openhab & mosqitto

here is my logfile after i added the logger line:

openhab_log.xml (336.8 KB)

thanks again! i will answer again later today.

Caused by: Connection refused

From your openHAB server, the IP address you specified to reach the MQTT broker


is responding that it has nothing listening on port 1883.

well my intentions were to start step by step so i dont really have anythings listening to mosquitto other than MQTT.fx on my laptop.

i will try to connect an ESP8266 to Mosquitto later today so I have a client listening.

for fast and easy MQTT debug, use the MyMQTT app on android, I mentioned it in another thread. Its very handy to test pub and sub with ease :slight_smile:

1 Like

Hey Stuart.
I got that App on my Android. But isnt it basically the same as MQTT.fx?
Didnt bother to monitor Mosquitto with it during my tests yesterday. but i will try today.
Used MQTT.fx to monitor the “/#” feed.

so i configured an esp8266 to listen to “inTopic” on

Via MQTT.fx or mosquitto_pub -h -t 'inTopic' -m 'TEST'
i can communicate with the ESP over Mosquitto.

So I changed my itemes file:

Switch mqttsw1 {mqtt=">[mosquitto:inTopic:command:ON:1],>[mosquitto:inTopic:command:OFF:0]"}

BUT Still no messages on Mosquitto via openHAB.

I tought sending binary values with mqtt via openhab should be pretty easy… well well how wrong :confused:

Did you get another

Caused by: Connection refused

in the log?

somehow the logfile stops at 2016-03-01.
whats the reason for this ? how can i fix this ?

btw my bindings are all 1.8.1 but in the log it say openHAB runtime v1.8.0 has started. could there be an issue ?

i used this tutorial to install openhab:
so the “wget” method not apt-get install.
java was already installed. i use the latest rasbian jessie.

i have a 2016_03_02.request.log file.

2016_03_02.xml (34.0 KB)

Julian, were you able to fix the issue? I’m running to the same issue using Openhab 1.8.3.I have a few mosquitto clients sub/pub with no issue.

His problem was solved with a setup from scratch, take a look here:

can confirm that a resetup with the official tutorials worked