I try to get the MQTT Bindung to talk to some other Raspberry Pis. Previously I used the MQTT Action Binding with some rules to send specific text values to the berries.
With the new released openHAB 2.5 I want to implement the MQTT Binding using switches and channels. Even If I tried several guides and the official description of the binding, I cant receive any messages on other berries.
I am using the embedded broker, created a MQTT generic thing and connected to a Switch Channel (“MQTT command topic” is “test”). Changing the state of the switch to ON or OFF shall send “ON” or “OFF”.
No error messages are at the log files and the broker and generic thing are ONLINE / INITIALIZED.
With the other PI I subscribe to the topic “test” (like I did with the MQTT Action binding) :
mosquitto_sub –t test
Switching the MQTT-Switch doesn’t give me any response at the subscribed topic.
I really don’t know my mistake – Could be the subscription to the topic “test” by the mosquitto client the wrong approach?
Simplify and make changes gradually. Presumably if you had this working with the MQTT v1 binding working using the MQTT Action, you have Mosquitto or some other external broker running. Keep using that. Honestly, the embedded broker is no longer maintained and probably shouldn’t be used anyway, but you definitely don’t want to move from a solid broker like Mosquitto to that.
Keep your Rules the same. Once you have your Broker Thing connected and Online, you can publish messages using
actions.getAction("mqtt", "broker:thing:id").publishMQTT("topic", "message", false) // last argument is the retained flag
Once that works, then move to creating the Generic MQTT Things and Channels to replace your Rules.
Minimize your changes to make it easier to find where it went wrong.