Hi all.
My problem is that Openhab seems to be initializing as an MQTT client and my items/rules are configured. Openhab connects to the local MQTT broker but never publishes to it even though I think Openhab reports that it is publishing - it even shows there are 2 publishers (I’m not sure where the second one comes from - a rogue socket perhaps?)
I am thinking… possibly Openhab thinks it is the broker and is sending messages to itself? It thinks it’s talking to the broker - my REAL broker even shows the successful connect. There are even PINGREQ packets from Openhab to my REAL broker, but something is wrong.
I have Mosquitto installed on a Raspberry Pi 2 and have been using it with ESP8266’s, Arduinos, etc. Everything seems to be working fine. I have used mosquitto_pub and mosquitto_sub to publish and subscribe topics. All devices that are subscribed to my test topics work as expected.
Yesterday I installed the Openhab runtime following the instructions on openhab.com. I also installed the demo site. Again, everything seems to be working fine and so I proceeded to install and configure Openhab MQTT binding. I think I understand the MQTT configurations in openhab.cfg, they are pretty straightforward. Btw, I am forcing authentication to Mosquitto.
After installing Openhab MQTT binding and configuring it in openhab.cfg I loaded up some terminal windows to do some testing.
I can see that the Openhab client successfully connects to the REAL MQTT broker (Mosquitto):
1458438690 New connection from 192.168.10.1 on port 1883.
1458438694: New client connected from 192.168.10.1 as Central (c1, k60, u’HomeGenie’).
(I previously tried HomeGenie and so I am using that same username. I’ll change it later)
On startup of openhab, the MQTT client seems to initialize correctly:
20:58:31.300 [INFO ] [.io.transport.mqtt.MqttService:108 ] - MQTT Service initialization completed.
20:58:31.305 [INFO ] [o.i.t.m.i.MqttBrokerConnection:114 ] - Starting MQTT broker connection 'mosquitto’
20:58:31.323 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:294 ] - Creating new client for ‘tcp://192.168.10.1:1883’ using id ‘Central’ and file store ‘/tmp/mosquitto’
Later in the startup log I see:
21:04:07.051 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item ‘DeckPostLightColor (Type=StringItem, State=Uninitialized)’ with ‘MqttGenericBindingProvider’ reader.
21:04:07.089 [DEBUG] [b.mqtt.internal.MqttItemConfig:72 ] - Loaded MQTT config for item ‘DeckPostLightColor’ : 0 subscribers, 1 publishers
21:04:07.102 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item ‘DeckPostLightSwitch (Type=SwitchItem, State=Uninitialized)’ with ‘MqttGenericBindingProvider’ reader.
21:04:07.148 [DEBUG] [b.mqtt.internal.MqttItemConfig:72 ] - Loaded MQTT config for item ‘DeckPostLightSwitch’ : 0 subscribers, 2 publishers
21:04:07.152 [DEBUG] [i.internal.GenericItemProvider:341 ] - Start processing binding configuration of Item ‘DeckPostLightAnimation (Type=NumberItem, State=Uninitialized)’ with ‘MqttGenericBindingProvider’ reader.
21:04:07.155 [DEBUG] [b.mqtt.internal.MqttItemConfig:72 ] - Loaded MQTT config for item ‘DeckPostLightAnimation’ : 0 subscribers, 1 publishers
21:04:07.231 [DEBUG] [m.internal.MqttEventBusBinding:68 ] - MQTT: Activating event bus binding.
When I go to the web ui on port 8080, I can see the RGB LED I’ve configured for testing. The controls look correct, I get the colorselector and make changes. Viewing the openhab.log in debug mode I can see these log entries:
20:56:20.609 [INFO ] [runtime.busevents :22 ] - DeckPostLight received command 114,50.98039215686274,100
20:56:22.508 [INFO ] [runtime.busevents :22 ] - DeckPostLight received command 37.92452830188679,41.568627450980394,100
20:56:23.554 [INFO ] [runtime.busevents :22 ] - DeckPostLight received command 350.90909090909093,38.8235294117647,100
20:56:25.922 [INFO ] [runtime.busevents :22 ] - DeckPostLight received command 268.2089552238806,52.549019607843135,100
If it helps, here is my item and rule configuration:
item
Group gDeckPostLight “Deck Post Lights” (gGF)
Color DeckPostLight “Deck Post Light Color” (gDeckPostLight)
String DeckPostLightColor (gDeckPostLight) {mqtt=">[mosquitto:HomeGenie/deckpostlight/color:command::default]"}
Switch DeckPostLightSwitch “W1” (gDeckPostLight) {mqtt=">[mosquitto:HomeGenie/deckpostlight/SW1:command:ON:100],>[mosquitto:/HomeGenie/deckpostlight/SW1:comman$
Number DeckPostLightAnimation “Deck Post Light Animation” (gDeckPostLight) {mqtt=">[mosquitto:HomeGenie/deckpostlight/animation:command::default]"}
rule
var HSBType hsbvalue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues
rule "Set RGB 2 value"
when
Item DeckPostLight changed
then
hsbvalue = DeckPostLight.state as HSBType
redValue = hsbvalue.red.intValue
greenValue = hsbValue.green.intValue
blueValue = hsbValue.blue.intValue
RGBValues = redValue.toString + “;” + greenValue.toString + “;” + blueValue.toString
sendCommand( DeckPostLightColor, RGBValues )
logInfo( “DeckPostLightColor”, RGBValues)
end
Also, Openhab and Mosquitto are on the same IP address of 192.168.10.1 and the Mosquitto ACL gives read and write access to all topics (#) for the HomeGenie user.
Can anyone please tell me how I might troubleshoot this problem?