MQTT binding throwing up exceptions


I have MQTT broker installed that successfully publishes messages form a range of ESP sensors. In an attempt to get my first rule working, after I stop OH2, clean the cache and restart OH2, I get these exceptions thown at me. They mean little to me but maybe they mean something to you? I seem to be using some invalid character in my MQTT config.

I only have one rule (and its not working as you can see from here ). My setup is also in this post. Maybe the solution to this MQTT eception will also solve my problem with the rules not working?

2020-12-09 21:56:31.945 [ERROR] [org.openhab.binding.mqtt ] - bundle org.openhab.binding.mqtt:2.5.10 (234)[org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService(282)] : The activate method has thrown an exception
java.lang.IllegalArgumentException: ID segment ‘MQTT on demeter’ contains invalid characters. Each segment of the ID must match the pattern [A-Za-z0-9_-]*.
at org.eclipse.smarthome.core.common.AbstractUID.validateSegment( ~[?:?]
at org.eclipse.smarthome.core.common.AbstractUID.( ~[?:?]
at org.eclipse.smarthome.core.common.AbstractUID.( ~[?:?]
at org.eclipse.smarthome.core.thing.UID.( ~[?:?]
at org.eclipse.smarthome.core.thing.ThingUID.( ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.brokerAdded( ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.lambda$1( ~[?:?]
at java.util.concurrent.ConcurrentHashMap.forEach( ~[?:1.8.0_272]
at java.util.Collections$UnmodifiableMap.forEach( ~[?:1.8.0_272]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.startBackgroundDiscovery( ~[?:?]
at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.activate( ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.activate( ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_272]
at sun.reflect.NativeMethodAccessorImpl.invoke( ~[?:1.8.0_272]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:1.8.0_272]
at java.lang.reflect.Method.invoke( ~[?:1.8.0_272]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod( ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500( ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke( ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke( ~[?:?]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke( ~[?:?]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke( ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject( ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent( ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService( ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal( ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal( ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal( ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable( ~[?:?]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents( ~[?:?]
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable( ~[?:?]
at org.apache.felix.scr.impl.Activator.loadComponents( ~[?:?]
at org.apache.felix.scr.impl.Activator.access$200( ~[?:?]
at org.apache.felix.scr.impl.Activator$ScrExtension.start( ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.createExtension( ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle( ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle( ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified( ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified( ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.track( ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged( ~[osgi.core-6.0.0.jar:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.container.Module.publishEvent( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.container.Module.start( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start( ~[org.eclipse.osgi-3.12.100.jar:?]
at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle( ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle( ~[?:?]
at org.apache.karaf.features.internal.service.Deployer.deploy( ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision( ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13( ~[?:?]
at [?:1.8.0_272]
at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:1.8.0_272]
at java.util.concurrent.ThreadPoolExecutor$ [?:1.8.0_272]
at [?:1.8.0_272]
2020-12-09 21:56:32.128 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘’ with clientid 1b7d76df-2479-4f14-XXXX-XXXXXXXXX

Why are you doing this? You should only ever clear the cache if you are experiencing a specific type of problem.

The error indicates you have a Thing ID that is not properly formed. Since you are using .things files this is where I stop. Trying to deal with .things files is just a huge time sink and I would rather spend my time elsewhere. When you create Thing through the UI you never encounter syntax errors like these.

Ok, fair point, I get contradictory views from this forum. Some like you say that we shouldn’t be configuring text files, others say its the best way to learn.

I just noticed that before kicking that error, I got a few extra lines before the exception:

2020-12-09 22:23:58.514 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homie.internal.discovery.Homie300Discovery@11df9ed from discovery topic homeassistant/# on broker mqtt:broker:mymqtt but topic not registered for listener. Check discovery logic!
2020-12-09 22:23:58.559 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@151628a from discovery topic +/+/$homie on broker mqtt:broker:mymqtt but topic not registered at all. Check discovery logic!
2020-12-09 22:23:58.563 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@151628a from discovery topic homeassistant/# on broker mqtt:broker:mymqtt but topic not registered at all. Check discovery logic!
2020-12-09 22:23:58.566 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@151628a from discovery topic +/+/$homie on broker mqtt:broker:mymqtt but topic not registered at all. Check discovery logic!
2020-12-09 22:24:03.741 [INFO ] [basic.internal.servlet.WebAppServlet] - Stopped Basic UI

It’s going on about homeassistant and homie discovery but I have no such bindings installed.

I’m not saying what you should use or not use. I just won’t spend my time any more helping with .things file syntax errors.

Those are warning so not a real problem. And the MQTT binding is able to automatically discover MQTT devies that follow either the Homie or Home Assistant standard. I’m not sure why you are getting the warnings but they are likely benign and can be ignored.

Well ok, given that I have the thing configure and linked to the Item in the PaperUI, how do I create the rule without using the text files? The power of OH2 lies in the action->reaction model, otherwise not really that useful? I need to have a working rule to keep the motivation going :slight_smile:

You don’t (easily) in openHAB 2, and that’s not what Rich is saying either.

He’s just talking about Things files, not any other type of configuration files.

Just to elaborate a bit on hafniumzinc’s reply. As he said, I only reserve my time from helping with .things file syntax problems. I’ve spent plenty of my time doing so in the past and have come to the conclusion that over all users and helpers on the forum there would be a net gain in productivity and a net reduction in frustration if people create or discover all their Things through the UI.

But for everything else it’s about the same through the UI or text configs so I’m more than happy to help with those.

And you can create rules through PaperUI if you want to if you install the Next-Gen Rules Engine (which is the rule engine that OH 3 uses). However, PaperUI is really buggy and not complete so I don’t recommend creating your rules using PaperUI. But in MainUI I’m becoming a really big fan of creating rules through the UI too.