Reputation: 681
As a sample test, I just want to ON/OFF a bulb using OpenHab via wifi. So I connect the hivemq server and openhab as follows in the openhab configuration.
mqtt:broker.url=tcp://127.0.0.1:1883
mqtt:broker.clientId=openhab
So when starting openhab I can see following in the console.
2016-09-01 19:18:11.692 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2016-09-01 19:18:11.695 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2016-09-01 19:18:13.092 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
So it seems openhab and hivemq connected successfully. Then I created following file on openhab distribution.
home.sitemap
sitemap home label="My House"
{
Frame label="ESP Module"{
Group item=FF_Bed label="Front Porch"
}
}
home.items
Group All
Group gGF (All)
Group gFF (All)
Group GF_Living "Living Room" <video> (gGF)
Group FF_Bed "Bedroom" <bedroom> (gFF)
Dimmer Light_GF_Living_Table "Table" (GF_Living, Lights) {mqtt="<[mybroker:/myHome/Table:command:ON]"}
Switch Light_FF_Bed_Ceiling "Ceiling" (FF_Bed, Lights) {mqtt="<[mybroker:/myHome/doorbell:command:ON]"}
/* Locations */
Location HomeLocation MyHome
esp-pic.map
0=Still
1=Motion
I can see above specified items on my openhab site. But when I click on the light there are no updates from the MQTT server. But I can see following on OpenHab console.
2016-09-02 12:00:35.484 [INFO ] [runtime.busevents ] - Light_FF_Bed_Ceiling received command ON
So why it doesn't publish this change to HiveMQ topic?
Thanks.
Upvotes: 0
Views: 878
Reputation: 782
You can only have inbound or outbound mqtt messages in openHAB.
Your current configuration in home.items is inbound because of the "<"-sign. If you want to a click on the switch to cause a mqtt-message to be published to the broker, you have to change it to the ">"-sign.
For reference have look on this page: https://github.com/openhab/openhab/wiki/MQTT-Binding and search for inbound or outbound messages
Upvotes: 3