Hello All,
I’ve struggled my way through to the point I’m at now. I keep spending days on what seem to be simple issues but are not widely documented.
My latest issue is that I am able to publish messages to my mosquito broker both with openHAB and with my ESP8266 device. Verified this with a subscriber listener that is able to show receipt of messages from both clients as I’m subscribed and publishing under the same topic hierarchy. The problem is that openHAB and my ESP8266 as subscribers aren’t receiving messages from the other respectively.
Some new details and my configuration below:
In my openhab.cfg file I have:
mqtt:ESP8266.url=tcp://192.168.0.17:1883
mqtt:ESP8266.clientId=openhab
In my Items file I have:
Group All
Switch mqttsw1 “Switch 1” (all) {mqtt=">[ESP8266:/F1/R00/D01/I06:command:on:1],>[ESP8266:/F1/R00/D01/I06:command:off:0]"}
Switch mqttsw2 “Switch 2” (all) {mqtt=">[ESP8266:/F1/R00/D01/I02:command:off:0],>[ESP8266:/F1/R00/D01/I02:command:on:1]"}
Contact mqttcon1 “Front Door” (All) {mqtt="<[ESP8266:/F1/R00/D01/I01:command:open:1],<[ESP8266:/F1/R00/D01/I01:command:closed:0]"}
And my Sitemap:
sitemap dolphin label=“Main Menu”
{
Frame label=“MQTT” {
Switch item=mqttsw1 label=“MQTT Switch 1”
Switch item=mqttsw2 label=“MQTT Switch 2”
Switch item=mqttcon1
}
}
I have validated that hitting the switch for Switch 1 and Switch two generate a message received when subscribing:
mosquitto_sub -d -t /F1/R00/D01/#
Client mosqsub/2716-raspberryp sending CONNECT
Client mosqsub/2716-raspberryp received CONNACK
Client mosqsub/2716-raspberryp sending SUBSCRIBE (Mid: 1, Topic: /F1/R00/D01/#, QoS: 0)
Client mosqsub/2716-raspberryp received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/2716-raspberryp received PUBLISH (d0, q0, r0, m0, ‘/F1/R00/D01/I06’, … (1 bytes))
1
When running the same subscribe from another raspberry pi it doesn’t pick up the message. It seems that the messages aren’t making it out onto my network… but I would have thought that openhab being installed on the same machine as my broker would be able to pick up the messages, but that doesn’t seem to be the case.
void door_open() {
// turn on wifi if we aren't connected
if(WiFi.status() != WL_CONNECTED) {
wifi_init();
}
Serial.println("Sending to Broker");
mqtt_client.publish("/F1/R00/D01/I01","1");
PrevDoor = HIGH;
}
void door_closed() {
// turn on wifi if we aren't connected
if(WiFi.status() != WL_CONNECTED) {
wifi_init();
}
Serial.println("Sending to Broker");
mqtt_client.publish("/F1/R00/D01/I01","0");
PrevDoor = LOW;
}
The above is my Arduino code showing the type and message being sent from that end and should merry up to mqttcon1 item.