Hello, I’m new to openHAB, started with OH2, and new to MQTT. I have mosquitto installed on the same rPi as OH2. I am able to publish readings from a DHT-22 sensor wired to a ESP-12E to the mosquitto server under the topic openhab/humidor/temperature and openhab/humidor/humidity. It publishes about every 3 or 4 minutes, but I want to lower that to hourly for battery operation once I get everything working. Currently I am passing in characters rounded to the nearest whole number. I am unable to view this information from a sitemap homeTest. I have been reading and tweaking with it for hours now and I feel like I am going backwards. Update: I apparently had it working at some point, I went to another computer where I had the sitemap pulled up from a day or two ago and saw both the temperature and humidity. I have no idea what my mqtt.items looked like at the time it was working. I know when I had the page pulled up at first it read no values, so I think I gave up and then the next day started working on it again with my laptop. It takes so much longer for the values to show up in the sitemap compared to when the message shows up on the queue; it has to be over 20 minutes or I would have seen it working when it was working.
Here is output from mosquitto_sub -t “#” -v
openhab/humidor/temperature 67
openhab/humidor/humidity 86
mosquitto_sub -t "openhab/humidor/temperature"
67
mosquitto_sub -t "openhab/humidor/humidity"
86
Here are the uncommented plines from mqtt.cfg
mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab2
I originally set the mqtt-eventbus.cfg, but realized that my settings were incorrect and that I didn’t think I wanted it set. I commented out my changes and then deleted the config from Karaf. I verified that the mqtt-eventbus.cfg did not show back up after restarting OH2.
openhab> config:property-list
mosquitto.clientId = openhab2
mosquitto.url = tcp://localhost:1883
service.pid = org.openhab.mqtt
I have set DEBUG to logging for org.openhab.binding.mqtt and org.openhab.mqtt.
Here is my mqtt log:
openhab> log:tail | grep mqtt
19:32:24.424 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mqtt.items’
19:35:38.402 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent INSTALLED - org.openhab.binding.mqtt
19:35:41.797 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent RESOLVED - org.openhab.binding.mqtt
19:35:44.820 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
19:35:44.863 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto’
19:35:45.674 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTING - org.openhab.binding.mqtt
19:35:45.768 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
19:35:46.444 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
19:35:46.546 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=151, service.id=274, service.bundleid=177, service.scope=bundle} - org.openhab.binding.mqtt
19:35:46.836 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={event.topics=openhab/, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=152, service.id=276, service.bundleid=177, service.scope=bundle} - org.openhab.binding.mqtt
19:35:47.226 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=153, service.id=275, service.bundleid=177, service.scope=bundle} - org.openhab.binding.mqtt
19:35:47.392 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTED - org.openhab.binding.mqtt
19:35:47.488 [INFO ] [core.karaf.internal.FeatureInstaller] - Installed 'openhab-binding-mqtt’
19:35:47.538 [INFO ] [smarthome.event.ExtensionEvent ] - Extension ‘binding-mqtt’ has been installed.
Here are my items:
Group Humidor_Hum_Temp
Number Humidor_Temp (Humidor_Hum_Temp) <temperature> {mqtt="<[mosquitto:openhab/humidor/temperature:state:default]"}
Number Humidor_Hum (Humidor_Hum_Temp) <water> {mqtt="<[mosquitto:openhab/humidor/humidity:state:default]"}
And the portion of my sitemap:
Frame label=“Humidor” {
Text label=“temperature” item=Humidor_Temp icon="temperature"
Text label=“humidity” item=Humidor_Hum icon=“water”
}
At one point last night the temperature seemed to be working but I have messed around with the mqtt.items file a lot and I seem to have broken it. Humidity never worked. I think I had something like this under temperature when it worked, but I had to leave the sitemap open for over 10 minutes before it would show up:
Number Humidor_Temp "Temperature [%.1f]" (Humidor_Hum_Temp) <temperature> {mqtt="<[mosquitto:openhab/humidor/temperature:state:default]"}
When I load the sitemap I receive this in the log:
22:13:25.266 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text
22:13:25.280 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text
22:13:25.303 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Humidor_Hum’ for widget org.eclipse.smarthome.model.sitemap.Text
22:13:25.325 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Humidor_Hum’ for widget org.eclipse.smarthome.model.sitemap.Text
22:13:25.344 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Humidor_Hum’ for widget org.eclipse.smarthome.model.sitemap.Text
And when I edit the mqtt.items I receive this:
22:13:43.407 [INFO ] [smarthome.event.ItemRemovedEvent ] - Item ‘Humidor_Hum_Temp’ has been removed.
22:13:43.457 [INFO ] [smarthome.event.ItemRemovedEvent ] - Item ‘Humidor_Temp’ has been removed.
22:13:43.598 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mqtt.items’
22:13:43.687 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘mqtt.items’
Here is an excerpt from my mosquitto log, I think most of the time when openhab2 disconnected it was due to a service restart. The last one I had not restarted the service in a while.
1481224120: New client connected from 127.0.0.1 as openhab2 (c1, k60).
1481225095: Socket error on client openhab2, disconnecting.
1481225145: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1481225747: New connection from 127.0.0.1 on port 1883.
1481225747: New client connected from 127.0.0.1 as openhab2 (c1, k60).
1481226947: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1481228748: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1481230549: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1481232350: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1481233955: New connection from ::1 on port 1883.
1481233955: New client connected from ::1 as mosqsub/21228-openhab (c1, k60).
1481234033: Socket error on client mosqsub/21228-openhab, disconnecting.
1481234062: New connection from ::1 on port 1883.
1481234062: New client connected from ::1 as mosqsub/21268-openhab (c1, k60).
1481234085: New connection from ::1 on port 1883.
1481234085: New client connected from ::1 as mosqsub/21274-openhab (c1, k60).
1481234151: Socket error on client mosqsub/21274-openhab, disconnecting.