Send message to MQTT Generic thing using mosquitto_pub

I am trying to send message to MQTT Generic thing with the following command:

mosquitto_pub -h -d -p 8883 -u username -P password -t ‘mqtt:topic:139605c97f:temperature’ -m 32

Tracking the log:tail I don’t see anything and the temperature in my generic thing doesn’t change.
How do I figure out the topic name ? It seems that what I am using is wrong. I don’t know how to determine the correct topic parameter.


MQTT topics do not use colons.

Either way, it may be worth checking out some MQTT fundamentals first, because what you’re trying to do will never give you the result you expect.

That seems to be the openhab channel id, not an mqtt topic. You’re confusing the two.

You need to find out what that openhab channel’s MQTT Topic first, (stateTopic). Then you publish your message using that topic using mosquitto_pub

Here’s a copy pasted example from my system:

Thing mqtt:topic:studyroom-thermometer "Study Room Thermometer" (mqtt:broker:mosquitto) [ availabilityTopic="zigbee/studyroom-thermometer/availability", payloadAvailable="online", payloadNotAvailable="offline" ] {
         Type number        : temperature  [ stateTopic="zigbee/studyroom-thermometer/temperature", unit="°C" ]
         Type number        : humidity     [ stateTopic="zigbee/studyroom-thermometer/humidity", unit="%" ]
         Type number        : pressure     [ stateTopic="zigbee/studyroom-thermometer/pressure", unit="mbar" ]
         Type number        : linkquality  [ stateTopic="zigbee/studyroom-thermometer/linkquality" ]
         Type contact       : availability [ stateTopic="zigbee/studyroom-thermometer/availability", on="online", off="offline" ]
         Type number        : battery      [ stateTopic="zigbee/studyroom-thermometer/battery", unit="%" ]

As you see, my openhab thing is called mqtt:topic:studyroom-thermometer and the temperature channel is mqtt:topic:studyroom-thermometer:temperature. Its MQTT stateTopic is zigbee/studyroom-thermometer/temperature

So to publish a value that openhab channel/item will pick up for the mqtt:topic:studyroom-thermometer:temperature channel, I would do

mosquitto_pub -h myserver -t zigbee/studyroom-thermometer/temperature -m 24