julianb
(Julian Balles)
March 1, 2016, 9:58pm
1
Hello !
im tying to make a MQTT Switch.
my MQTT.sitemap looks like this:
Code:
sitemap MQTT label="mqtt"
{
Frame label="MQTT" {
Switch item=mqttsw1 label="MQTT Switch 1"
}
the Items File:
Code:
Switch mqttsw1 {mqtt=">[mosquitto:/home:command:ON:1],>[mosquitto:/home:command:OFF:0]"}
The openhab.cfg:
Code:
mqtt:mosquitto.url=tcp://192.168.178.78:1883
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.
watou
(John Cocula)
March 1, 2016, 10:02pm
2
Did you install the MQTT binding JAR, not the action JAR?
julianb
(Julian Balles)
March 1, 2016, 10:07pm
3
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 ?
watou
(John Cocula)
March 1, 2016, 10:09pm
4
Is mosquitto set to listen for connections on that interface, 192.168.178.78, or is it just listening on 127.0.0.1 (or localhost)?
julianb
(Julian Balles)
March 1, 2016, 10:14pm
5
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 192.168.178.78:1883 in the mqtt.fx setup.
maybe i dont understand your question. where can i check to give you an answer ?
watou
(John Cocula)
March 1, 2016, 10:28pm
6
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 192.168.178.78, 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.
julianb
(Julian Balles)
March 1, 2016, 11:09pm
7
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:
bind_address 192.168.178.78
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.
watou
(John Cocula)
March 2, 2016, 12:06am
8
Caused by: java.net.ConnectException: Connection refused
From your openHAB server, the IP address you specified to reach the MQTT broker
mqtt:mosquitto.url=tcp://192.168.178.78:1883
is responding that it has nothing listening on port 1883.
julianb
(Julian Balles)
March 2, 2016, 5:04am
9
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
1 Like
julianb
(Julian Balles)
March 2, 2016, 9:36am
11
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.
julianb
(Julian Balles)
March 2, 2016, 7:07pm
12
so i configured an esp8266 to listen to “inTopic” on 192.168.178.78:1883
Via MQTT.fx or mosquitto_pub -h 192.168.178.78 -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
watou
(John Cocula)
March 2, 2016, 7:41pm
13
Did you get another
Caused by: java.net.ConnectException: Connection refused
in the log?
julianb
(Julian Balles)
March 2, 2016, 7:52pm
14
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: https://klenzel.de/3094
so the “wget” method not apt-get install.
java was already installed. i use the latest rasbian jessie.
julianb
(Julian Balles)
March 2, 2016, 8:05pm
15
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.
sihui
(SiHui)
June 10, 2016, 6:17pm
17
His problem was solved with a setup from scratch, take a look here:
sihui:
This discussion was continued over private message, for future reference: the system (Raspbian Jessie) was set up from scratch using the following tutorial and now works fine with mosquitto and mqtt: Login via ssh pi@raspberrypi:~ $ sudo apt-get update pi@raspberrypi:~ $ sudo apt-get upgrade install mosquitto: pi@raspberrypi:~ $ wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key pi@raspberrypi:~ $ sudo apt-key add mosquitto-repo.gpg.key pi@raspberrypi:~ $ cd /etc/apt/sources.lis…
julianb
(Julian Balles)
June 11, 2016, 5:21pm
18
can confirm that a resetup with the official tutorials worked