The Simplest Configuration of OpenHAB/MQTT-Binding, According To a OpenHAB Documentation Example, Just Refuse To Work
& Although Iāve Put Through a Detailed OpenHAB PR (#4589) Regarding This Issue,
The MQTT-Binding Maintainer Seem To Believe That This Isnāt a OpenHAB Bug.
Many if not most of the users on this forum are successfully using the MQTT binding.
The appropriate place to get help with configuration and problems like these (as @watou suggested twice) is here on this forum. Only after a discussion here and consensus reached should an issue be raised on github.
The problem is one of configuration, not in the code. Therefore a github issue is not appropriate and why it was closed.
Have you verified in the logs that the MQTT binding is successfully connecting to the broker?
Have you use a test tool like mqtt_sub to verify that messages are being posted to the brokerās topics?
Have you verified there are no error in the log when sending/receiving messages?
Have you configured your Items exactly as @watou suggested in the thread on github?
Yes, Iāve Verified The OpenHAB/MQTT-Binding<>MQTT-Broker Connection :
Both By Inspecting The OpenHAB Log ( See : An Exemplary Log Snippet (As On PR #4589) ) & By Using a MQTT Client (Mosquitto mosquitto_sub) To Inspect The Defined āstateā MQTT-Topic.,
Also, Iāve Configured My Items EXACTLY As Suggested By @watou .
No Messages Are Posted By OpenHAB To Any Of The Defined MQTT-Topics.,
Also, As Can Be Seen In The Aforementioned OpenHAB Log Snippet, OpenHAB Seem NOT To Connect - At All - To The ācmdā MQTT-Topic (Contrary To The āstateā MQTT-Topic - To Which It Successfully Connects).
With The Hope That It Might Provide Some Useful Clue,
Here Is The Relevant Debugging Output Of The Mosquitto MQTT-Broker :
/var/log/mosquitto/mosquitto.log
1472095499: mosquitto version 1.4.9 (build date 2016-08-13 08:57:43+0300) starting
1472095499: Config loaded from /etc/mosquitto/mosquitto.conf.
1472095499: Opening ipv4 listen socket on port 1883.
1472095499: Opening ipv6 listen socket on port 1883.
<...>
1472097488: New connection from 10.0.0.1 on port 1883.
1472097488: New client connected from 10.0.0.1 as openhab2 (c1, k60).
1472097488: Sending CONNACK to openhab2 (0, 0)
1472097488: Received SUBSCRIBE from openhab2
1472097488: /openhab/test1234/state (QoS 0)
1472097488: openhab2 0 /openhab/test1234/state
1472097488: Sending SUBACK to openhab2
1472097548: Received PINGREQ from openhab2
1472097548: Sending PINGRESP to openhab2
It is proper forum etiquette to post everything the volunteers need to help you with your problem here in this thread. Donāt make us go somewhere else to see your code, logs, etc. About 90% of the time Iām posting from my phone. It is all but impossible to keep switching back and forth between two pages to follow the conversation. Others simply wont bother.
As @pahansen said, he and I have encountered difficulty using topics that start with ā/ā. This is actually documented as undesirable on the mosquitto site.
Remove the leading ā/ā and make sure your publishers and subscribers are using identical topics.
If that doesnāt work, post your configs and Items here.
What you are trying to do with the command sections of the item is āpublishā the command. The thing that you are trying to control to should be subscribed to the same topic.
EDIT: with MQTT.fx running you should be able to view the traffic live by subscribing to the same topic.
You can deal with subscribing to the state topic once you get the command working (if needed).
EDIT2:
You have the item defined in both your sitemap and items file. This might be another issue, but I am not sure.
In my items, I have a line as follows which defines an item group:
Group GF_Mancave "Man Cave" <office> (gGF)
I then have the item as defined in the post above, so it is only defined once.
The relevant sitemap entry for me is as follows:
Group item=gGF label="Ground Floor" icon="groundfloor"
For Watching The MQTT Activity, I Currently Use : Mosquittoā Log File & Mosquittoā mosquitto_sub Utility.
Iāll Most Probably Give a Graphic Counterpart, Such As MQTT.fx, a Try Later On.
& Shouldnāt OpenHAB Subscribe To The ācmdā MQTT-Topic⦠Just Like It Does (Did) To The āstateā One ?
My .sitemap Syntax Was Shamelessly Copied From The OpenHAB ādemoā One :
Well, I Do Believe That OpenHAB Should Subscribe To The ācmdā MQTT-Topic, For Publishing Commands Thru It & Yes, It Has To Be Some Glitch Somewhereā¦
Thanks A Bunch For Trying To Help ! & If You Figure Something Out Of This, Kindly Update
No, a subscription is only needed to read messages. A publisher does not subscribe to a the topic it sends messages to.
It isnāt a problem. Putting Items on the sitemap does not create new Items or interfere with existing Items. It does let you control how it appears in ways not possible when only using groups on the sittemap (e.g show a Switch as text, hide Items when they are a certain state, etc.
The āopenhab/ā is just the first part of the topic name and has no relationship with the clientid
Here is another example working MQTT publishing Item:
Switch T_D_Garage1_MQTT "Garage Door 1" <garagedoor> { mqtt=">[mosquitto:actuators/garage1:command:*:default]"}
It doesnāt get any simpler than that. When the switch receives a command it publishes ON or OFF to actuators/garage1 on the mosquitto broker (as defined in the config).
As On PR #4589, While OpenHAB Seem To Be Able To Successfully Communicate With The Mosquitto MQTT-Broker, The OpenHAB Web-UI (Basic) Still Shows No Items At All :
Where is your sitemap file? That screenshot indicates that there is no sitemap file or a default one. In any case, your sitemap file is not being used.