Ok, I’m lost and I need directions. I have mosquitto installed on a pi at address 192.168.2.21, and it has been working fine for a year. I have installed openhabian on a different pi at 192.168.2.55, and it has a z-stick plugged in and talking to a whole house power monitor just fine. It even works when I’m remote via nginx. I’ve installed the openhab app on my android and I can see power consumption etc. Now I’ve decided to try to route the MQTT traffic through openhab, so that I can view and control my items with openhab. But I’m still missing some piece. Here’s what I have (where \OPENHABIANPI\ is the network location, as I’m working in windows and have the samba server running on the pi) :
I modified the file \OPENHABIANPI\openHAB-conf\services\mqtt.cfg to include the line
localMQTT.url=tcp://192.168.2.21:1883
every other line in the file is commented #
I created a file \OPENHABIANPI\openHAB-conf\sitemaps\main1.sitemap that file contains:
sitemap main1 label=“hvac”
{
Number item=temperature label=“0068ae2ae”
}
and I create a file \OPENHABIANPI\openHAB-conf\items\test1234.items that contains:
Number temperature “temp [%.1f]” {mqtt="<[localMQTT:hvac/0068ab630:state:default]"}
I modified the file \OPENHABIANPI\openHAB-conf\services\mqtt-eventbus.cfg so that the following two lines are not commented:
broker=localMQTT
stateSubscribeTopic=/hvac/0068ab630/${item}/state
I know MQTT broker is working and publishing to the topic hvac/0068ab630. In the android app, I can see the hvac sitemap (I also see the “Home” sitemap that has the Power monitor under it). But there are no “things” under hvac.
In \OPENHABIANPI\openHAB-log\openhab.log I see the lines:
2017-06-29 00:31:21.600 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-06-29 00:31:21.606 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘localmqtt’
What am I missing? Do I need something in \OPENHABIANPI\openHAB-conf\things\ ?
----Pre-Coffee response—
Your configs (items, sitemap, mqtt.cfg) look good to me.
You don’t really need the mqtt-eventbus since you are subscribing to the topic using the item config.
The MQTT binding is a 1.x binding, so it doesn’t follow the Things concept from openHAB 2.x.
Try to debug the OH2 ↔ Broker connection: Enter in the openHAB console using the commands below
ssh into the openHABian system and then:
sudo su
ssh openhab@localhost -p 8101 // with password: habopen
log:set DEBUG org.openhab.binding.mqtt
log:set DEBUG org.openhab.io.transport.mqtt
logout // from the OH2 console
tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log
To start clean and to make troubleshooting easier, I would recommend:
Keep your /etc/openhab2/services/mqtt.cfg (aka openHAB-conf\services\mqtt.cfg) as is, comment out everything in mqtt-eventbus.cfg, delete /var/lib/openhab2/config/org/openhab/mqtt.config & mqtt-eventbus.config (if it exists), restart OH2 with DEBUG logging enabled on the binding.
You don’t see the temperature item being listed at all ? (even without any value?)
This means that you may have a problem with the main1.sitemap file.
Edit: (my bad) Of course you won’t see it… I modified the first line of my post
This I also just noticed. in the console: openhab> smarthome:items list ZWaveNode2_SensorPower (Type=NumberItem, State=2357.28, Label=Energy Consumption, Category=Energy) PowerMonitor_ElectricMeterWatts2 (Type=NumberItem, State=1450.92, Label=Electric Power Consumption, Category=Energy) PowerMonitor_ElectricMeterWatts1 (Type=NumberItem, State=906.72, Label=Electric Power Consumption, Category=Energy) PowerMonitor_SensorPower2 (Type=NumberItem, State=NULL, Label=Energy Consumption, Category=Energy) PowerMonitor_SensorPower1 (Type=NumberItem, State=NULL, Label=Energy Consumption, Category=Energy)
So the item temperature is not even listed. Shouldn’t it be?
Well, I found it. Turns out that since I’m publishing the temperature as a string, it has to be defined as a string item. So now my items file looks like this:
2017-07-03 20:08:32.334 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'test'
2017-07-03 20:08:32.355 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'm2m-eclipse'
2017-07-03 20:08:32.355 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
java.lang.IllegalArgumentException: tcp://10.0.0.26:8883/
at org.eclipse.paho.client.mqttv3.MqttConnectOptions.validateURI(MqttConnectOptions.java:433)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:260)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.MqttClient.(MqttClient.java:222)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.openConnection(MqttBrokerConnection.java:291)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.start(MqttBrokerConnection.java:112)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:109)[214:org.openhab.io.transport.mqtt:1.9.0]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189)[3:org.apache.felix.configadmin:1.8.12]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152)[3:org.apache.felix.configadmin:1.8.12]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85)[3:org.apache.felix.configadmin:1.8.12]
at org.apache.felix.cm.impl.ConfigurationManager$UpdateConfiguration.run(ConfigurationManager.java:1772)[3:org.apache.felix.configadmin:1.8.12]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)[3:org.apache.felix.configadmin:1.8.12]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)[3:org.apache.felix.configadmin:1.8.12]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]
I’m trying to access an MQTT Broker on raspberry Pi running Openhab2
You know the Story…
delete /var/lib/openhab2/config/org/openhab/mqtt.config and restart OH2
Root cause: Stale config entries kept in OH2 (port 8883 was most likely an older trial that you did to connect to the m2m-eclipse? Broker that was kept)
Also, it’s poor form to post the same question in two different threads. In the future, I’d suggest starting a new thread with your issue if it’s not related to the initial question in the current thread.