MQTT Subscribe (inbound) okay, but can't publish (outbound)?

Hello,

I’m using MQTT to receive/send commands from an ESP8266. I’m currently receiving update about the status, position, temperate, … (all inbound subscribe topic), but when I’m trying to “publish” (outbound) one, there’s nothing.

item :

Number GarageDoorPosition "Position [%d %%]" <garagedoor> {mqtt="<[mqttbroker:home/garage/position:state:default]"} Switch GarageDoorRelay "Ouvrir/Fermer" <switch> {mqtt=">[mqttbroker:home/garage/relay:command:ON:GO]"}

sitemap :

Text item=GarageDoorPosition label="Position" Switch item=GarageDoorRelay mappings=[ON="Go!"]

I can see the event in the events.log (and there’s no error in openhab.log)

2016-08-22 14:29:12.662 [ItemCommandEvent ] - Item 'GarageDoorRelay' received command ON

Got an idea what I did wrong?

Hi Sebastien!

Ummmmm… everything seems to be perfectly defined, I can’t see anything wrong in your item or sitemap definition.

Are you sure that the message is not being publish by openHAB to the broker?

For MQTT debugging purposes I always recommend installing a desktop or browser MQTT client application like MQTT.fx, MQTT-Spy or MQTTLens. Are you using any of those? Can you confirm that the MQTT message is not being published by openHAB?

Having a closer look at you item definition I see that you are sending a “GO” payload to the “home/garage/relay” topic when the GarageDoorRelay switch is turned on. Are you sure that your ESP8266 is expecting that payload and not an “ON” or 1?

Let’s see if we can fix this as soon as possible, I’m sure that the solution is going to be easy! :wink:

Best regards,

Aitor

Hello Aitor,

I’m not even using the ESP right now, just configuring and testing.

So, I’ve subbed to the topic, just to test.

I can send a mosquitto_pub to the topic and it’s working (test from console)

root@openHAB:/usr/home/nka # mosquitto_sub -d -t home/garage/relay
Client mosqsub/23016-openHAB sending CONNECT
Client mosqsub/23016-openHAB received CONNACK
Client mosqsub/23016-openHAB sending SUBSCRIBE (Mid: 1, Topic: home/garage/relay, QoS: 0)
Client mosqsub/23016-openHAB received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/23016-openHAB received PUBLISH (d0, q0, r0, m0, ‘home/garage/relay’, … (17 bytes))
test from console
Client mosqsub/23016-openHAB sending PINGREQ
Client mosqsub/23016-openHAB received PINGRESP

But when I press the button, I only see an “events”

2016-08-22 15:50:44.475 [ItemCommandEvent ] - Item 'GarageDoorRelay' received command ON

and I got nothing on the sub. (To be sure, I did a copy/past of the topic I’m using in the item.

I’ve seen something about adding mqtt config into the runtime.cfg. Is this true? It’s causing me error and it dosent make sens to me since I’m using mqtt.cfg

Thanks !

Guess what… not sure why, but restarting the server did the job.

:smiley:

Client mosqsub/23317-openHAB received PUBLISH (d0, q0, r0, m0, ‘home/garage/relay’, … (2 bytes))
GO

Strange… but this type of things do happen :wink:

If you see that the problem appears again don’t hesitate to write!