[RESOLVED] OH2.0 MQTT - Errors in log

Hi,
I have a working OH2.0 installation on Raspberry Pi.
Mosquitto installed on the pi as well and tested working with my device that’s subscribed via mqtt.
I can do the following in order to switch the light on and off:

Turn on: mosquitto_pub -t “/switch/Sonoff01AF” -m “1”
Turn off: mosquitto_pub -t “/switch/Sonoff01AF” -m “0”

in Paper UI I installed via Add-ons:
BINDINGS → MQTT Bindings (1.9.0.b5)
PERSISTENCE → MQTT Persistence (1.9.0.b5)
ACTIONS → MQTT Actions (1.9.0.b5)

Contents of /etc/openhab2/services/mqtt.cfg:

mosquitto.url=tcp://OH2IPAddress:1883
mosquitto.clientId=OpenHAB2
All other entries in this files are commented out with #.

My /etc/openhab2/sitemaps/demo.sitemaps contains:

Group item=gTFloor label=“Top Floor” icon=“secondfloor”

My demo.items file contains the following lines that were added to the demo content which was there already:

Group gTFloor “Top Floor”
Switch Light_Desktop “Amir_Study” (gTFloor) {mqtt=“>[mymosquitto:/switch/Sonoff01AF:command:ON:1],>[mymosquitto:/switch/Sonoff01AF:command:OFF:0]”}

I have installed the network bindings and can confirm I can see the mqtt device on the network (using its IP Address).

I now go to http://OH2IPAddress:8080/basicui/app
I can see in the top section Top Floor, when I click I see:
Study Room > followed by a switch.
It shows the status of the light as Online and the icon is green.
clicking on the switch turns the light to red but my mqtt device doesn’t change.

When I look at the log file /var/log/openhab2/openhab.log I see this entries:

2017-01-21 15:37:02.720 [WARN ] [nce.extensions.PersistenceExtensions] - There is no queryable persistence service registered with the id ‘mqtt’
2017-01-21 15:37:02.732 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘ut’: cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.persistence.HistoricItem.getState() on null
2017-01-21 16:00:04.246 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-01-21 16:00:04.251 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mymosquitto’
2017-01-21 16:00:04.318 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mosquitto’
2017-01-21 16:00:04.323 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘’
2017-01-21 16:00:04.444 [ERROR] [org.apache.felix.configadmin ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=279, bundle=182/mvn:org.openhab.action/org.openhab.action.mqtt/1.9.0.b5]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.9.0.b5
2017-01-21 16:02:46.827 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘demo.sitemap’
2017-01-21 16:05:14.619 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘demo.items’
2017-01-21 16:07:13.344 [WARN ] [nce.extensions.PersistenceExtensions] - There is no queryable persistence service registered with the id ‘mqtt’
2017-01-21 16:07:13.354 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule ‘ut’: cannot invoke method public abstract org.eclipse.smarthome.core.types.State org.eclipse.smarthome.core.persistence.HistoricItem.getState() on null

Can anyone point me in the correct direction of how I can troubleshoot this or find out what’s not setup correctly? (and tell me what other information can be provided to assist in the troubleshooting)
The mqtt device is a sonoff with a custom arduino script, but I don’t think this has any importance. It’s a working mqtt device.

Thanks in advance
Amir

I have been able to get the more details in the log file.
I can see in the log the entries below. Am hoping someone can shed some light on a possible solution:

2017-01-21 18:12:22.632 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:22.635 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:25.842 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘OFF’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:25.847 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘OFF’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:26.860 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:26.865 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:12:27.969 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command ON to /switch/Sonoff01AF
2017-01-21 18:12:28.904 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command OFF to /switch/Sonoff01AF
2017-01-21 18:20:41.510 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-01-21 18:20:41.515 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mymosquitto’
2017-01-21 18:20:41.529 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mosquitto’
2017-01-21 18:20:41.534 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘’
2017-01-21 18:20:41.540 [ERROR] [org.apache.felix.configadmin ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=279, bundle=182/mvn:org.openhab.action/org.openhab.action.mqtt/1.9.0.b5]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.9.0.b5
2017-01-21 18:21:08.361 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘OFF’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:21:08.368 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘OFF’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:21:09.192 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate command ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.
2017-01-21 18:21:09.201 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘ON’ for item ‘Sonoff1’ to handler for channel ‘network:device:192_168_200_163:online’, because no handler is assigned. Maybe the binding is not installed or not propertly initialized.

Try the following steps (simplifying for troubleshooting):

From Paper UI

  1. Uninstall MQTT Actions
  2. Uninstall MQTT Persistence
  3. Uninstall Network Binding
  4. Keep MQTT Binding (it wouldn’t hurt to re-install it)

Make sure that your /etc/openhab2/services/mqtt.cfg file is correct. It seems ok to me, but try also localhost :

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=OpenHAB2
All other entries in this files are commented out with #.

Remove file: /var/lib/openhab2/config/org/openhab/mqtt.config and restart OH2 (optionally, check this file before you delete it for errors… stale config parameters stored in there is usually a root cause for problems)

Check logs

Hi Dim,
I wasn’t able to uninstall the MQTT Actions.
I did remove the MQTT Persistence.
I proceeded to make a few more changes (undocumented :flushed:) and things are working now.
I did not re install the MQTT Persistence, but it’s installed now. So not sure what/why/how.

I actually gave up on openhab and started researching other platform. In one of the other platform i saw a similar syntax of the mqtt and decided to test it. It didn’t work but all of a sudden i noticed the OH2 was broadcasting the mqtt messages.

If time permits I will do a fresh install tomorrow on another SD Card and will document everything. Once ready I will “attempt” to create a step by step instructional on how to setup mqtt for oh2 on raspberry pi.

Thanks for your pointers.

Amir

1 Like

I suffered from this the whole day and in the end discovered that for some reason it is not enough to just modify the mqtt.cfg file and save it, for some reason I have to restart openhab for any change to this config file to take effect.

Hi all,

I would be very grateful if someone could help me trying to use the Adafruit MQTT broker with OH2 as a client.

I cannot seem to verify if it connects to io.adafruit.com at all.

Here is what I see from openhab.log when I logout…

2018-01-27 20:23:30.815 [INFO ] [penhab.io.transport.mqtt.MqttService] - Stopping broker connection '<io.adafruit.com'
2018-01-27 20:23:30.816 [INFO ] [penhab.io.transport.mqtt.MqttService] - Stopping broker connection 'io.adafruit.com'

When I restart OH2 (on Windows by the way), I see this in the log…

2018-01-27 20:28:08.947 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-01-27 20:28:09.889 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

here is my un-commented parts from mqtt.cfg:

io.adafruit.com.url=ssl://io.adafruit.com:8883

io.adafruit.com.clientId=<my key here>

# Optional. User id to authenticate with the broker.
io.adafruit.com.user=UglyKidJoe

# Optional. Password to authenticate with the broker.
io.adafruit.com.pwd=<my key here>

I’ve tried these combinations:
io.adafruit.com.url=ssl://io.adafruit.com:8883
io.adafruit.com.url=tcp://io.adafruit.com:1883
io.adafruit.com.url=https://io.adafruit.com:8883

And here is are the.items…

Switch TestSwitch {mqtt=">[io.adafruit.com:UglyKidJoe/feeds/on-off:command:1:MAP(onoff.map)],>[io.adafruit.com:UglyKidJoe/feeds/on-off:command:0:MAP(onoff.map)],<io.adafruit.com:UglyKidJoe/feeds/on-off:state:1:MAP(onoff.map)],<io.adafruit.com:UglyKidJoe/feeds/on-off:state:0:MAP(onoff.map)"}
Number OutsideTemperature "temperature [%.1f]" {mqtt="<[io.adafruit.com:UglyKidJoe/feeds/outside-temperature:state:default]"}

Each time I change something in mqtt.cfg is get the following…

2018-01-27 20:40:55.939 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-01-27 20:40:55.941 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'adafruit'
2018-01-27 20:40:56.363 [ERROR] [org.apache.felix.configadmin        ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=294, bundle=204/mvn:org.openhab.action/org.openhab.action.mqtt/1.10.0-SNAPSHOT]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.10.0-SNAPSHOT

Nothing happens with MQTT at all. But on MQTT.fx and io.adafruit.com all is well.

Thanks in advance guys

Try another broker alias (don’t use the FQDN since the dots may? cause the problem. If(?) the dots cause the problem, report here so we can either modify the docs to raise caution (not to use dots) or to raise a PR against the binding to allow dots in the broker alias.

mqtt.cfg

adafruit.url=ssl://io.adafruit.com:8883
adafruit.clientId=<my key here>
...

Additionally, try to re-install the MQTT Action Add-On and check the contents of /var/lib/openhab2/config/org/openhab/mqtt.config

Also: It’s much better to start a new thread and not to reply to a resolved case since not many people will read it :slight_smile:

@Dim, Thank you for your input.

It’s a good spot to eliminate the dots in the broker alias. It seemed to have allowed me to progress further.

Anyway, since I’m only using OH2 on Windows for some basic functionality testing (such as MQTT in this case), I set up a broker using CloudMQTT and it works fine with the following config…

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
cloudMQTT.url=tcp://m23.cloudmqtt.com:11438

# Optional. User id to authenticate with the broker.
cloudMQTT.user=dyhfquta

# Optional. Password to authenticate with the broker.
cloudMQTT.pwd=<my password>

This allows MQTT updates flawlessly. The following is published from my phone…

I think the same setup would work with AdafruitIO.

For interest here are the .items…

Switch Water_Pump 			"Water Pump" 					(Switches)				{ mqtt="<[cloudMQTT:home/switches/water-pump:state:default], >[cloudMQTT:home/switches/water-pump:command:*:default]" }

Number Temperature_Outside 	"Outside Temperature [%.1f °C]" (Weather, Temperature) 	{ mqtt="<[cloudMQTT:home/weather/temperature-outside:state:default]" }
String Humidity 			"Humidity" 						(Weather) 				{ mqtt="<[cloudMQTT:home/weather/humidity:state:default]" }
String Condition 			"Condition" 					(Weather) 				{ mqtt="<[cloudMQTT:home/weather/condition:state:default]" }

Thanks again for your help

1 Like

Well, i think this issue is still there in the 2.2 stable:disappointed_relieved:

I am using the mqtt actions in docker an install every Binding with the addons.cfg.

My mqtt-evenbus does only work when i install the mqtt-actions as last binding.

1 Like

Yes the issue is still there…Today I deleted the OH2 cache files, and my MQTT binding did not work anymore. I had to uninstall the MQTT action and then install it again. In this way the MQTT binding worked again.

1 Like