Yet another MQTT question

Ok, I’m lost and I need directions. I have mosquitto installed on a pi at address, and it has been working fine for a year. I have installed openhabian on a different pi at, 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
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:

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 ] [] - 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\ ?


Mega Edit (after drinking my first cup of coffee): Use:

sitemap main1 label="hvac"
Text item=temperature label="0068ae2ae"

There is no Number element type in sitemaps:
no need to do the below steps :stuck_out_tongue:

----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
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 :slight_smile:

1 Like

Thank you so much for the reply. I changed the sitemap to what you show. And now I see something under “hvac”, but its just the label:

But there is no value displayed. Also, I see this in /var/log/openhab2/openhab.log:

2017-07-02 16:44:53.491 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test1234.items’
2017-07-02 16:45:01.944 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'main1.sitemap’
2017-07-02 16:45:03.653 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘temperature’ for widget org.eclipse.smarthome.model.sitemap.Text
2017-07-02 16:45:03.656 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘temperature’ for widget org.eclipse.smarthome.model.sitemap.Text
2017-07-02 16:45:03.658 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text
2017-07-02 16:45:05.788 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
2017-07-02 16:45:07.267 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2017-07-02 16:45:07.855 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2017-07-02 16:45:09.313 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2017-07-02 16:45:10.805 [DEBUG] [ ] - BundleEvent STARTING -
2017-07-02 16:45:10.821 [DEBUG] [ ] - BundleEvent STARTED -
2017-07-02 16:45:10.846 [DEBUG] [] - Starting MQTT Service…
2017-07-02 16:45:10.909 [DEBUG] [ ] - ServiceEvent REGISTERED - {,}={, Connection Service,,, service.bundleid=187, service.scope=bundle} -
2017-07-02 16:45:10.949 [INFO ] [] - MQTT Service initialization completed.
2017-07-02 16:45:10.954 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'localmqtt’
2017-07-02 16:45:10.992 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTING - org.openhab.binding.mqtt
2017-07-02 16:45:11.000 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2017-07-02 16:45:11.037 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={,,, service.bundleid=191, service.scope=bundle} - org.openhab.binding.mqtt
2017-07-02 16:45:11.048 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Creating new client for ‘tcp://’ using id ‘openhab.1499028311028’ and file store '/var/lib/openhab2/tmp/localmqtt’
2017-07-02 16:45:11.091 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler,}={event.topics=openhab/,,,,, service.bundleid=191, service.scope=bundle} - org.openhab.binding.mqtt
2017-07-02 16:45:11.125 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2017-07-02 16:45:11.146 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/
,,,, service.bundleid=191, service.scope=bundle} - org.openhab.binding.mqtt
2017-07-02 16:45:11.165 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTED - org.openhab.binding.mqtt
2017-07-02 16:45:11.381 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Initializing MQTT Event Bus Binding
2017-07-02 16:45:11.441 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Subscriber for topic /hvac/0068ab630/+/state
2017-07-02 16:45:11.458 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ‘localmqtt’ on topic '/hvac/0068ab630/+/state’
2017-07-02 16:45:11.475 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT Event Bus Binding initialization completed.

So it looks like I’m still missing something. Any ideas?



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:

String inTemp "Value: [%s F]"  {mqtt="<[localMQTT:hvac/0068ab630:state:default]"}
String outTemp "Value: [%s F]"  {mqtt="<[localMQTT:hvac/0068ae2ae:state:default]"}

and both items now show up as items and display in the android app!

Thank you very much for helping me.

1 Like


A bit of Help Please

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] [] - Error starting broker connection
java.lang.IllegalArgumentException: tcp://
at org.eclipse.paho.client.mqttv3.MqttConnectOptions.validateURI([]
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.([]
at org.eclipse.paho.client.mqttv3.MqttClient.([]

I’m trying to access an MQTT Broker on raspberry Pi running Openhab2
You know the Story…

Heres my .cfg contents:


The rest is commented Out

I’ve spent hours Trying to Tackle this

I would appreciate Help

most likely, you are suffering from:

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)

edit: also: Help with MQTT please

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.

1 Like

Alright Sorry

Will do…

Number 1!!:grin:

Thank You @Dim Works fine now …

1 Like