MQTT binding throwing up exceptions

Hi,

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(AbstractUID.java:97) ~[?:?]
at org.eclipse.smarthome.core.common.AbstractUID.(AbstractUID.java:75) ~[?:?]
at org.eclipse.smarthome.core.common.AbstractUID.(AbstractUID.java:58) ~[?:?]
at org.eclipse.smarthome.core.thing.UID.(UID.java:57) ~[?:?]
at org.eclipse.smarthome.core.thing.ThingUID.(ThingUID.java:43) ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.brokerAdded(MqttServiceDiscoveryService.java:105) ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.lambda$1(MqttServiceDiscoveryService.java:85) ~[?:?]
at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[?:1.8.0_272]
at java.util.Collections$UnmodifiableMap.forEach(Collections.java:1507) ~[?:1.8.0_272]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.startBackgroundDiscovery(MqttServiceDiscoveryService.java:85) ~[?:?]
at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.activate(AbstractDiscoveryService.java:384) ~[?:?]
at org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService.activate(MqttServiceDiscoveryService.java:54) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_272]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_272]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_272]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_272]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[?:?]
at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) ~[?:?]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) ~[?:?]
at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:340) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:982) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:955) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:756) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) ~[?:?]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) ~[?:?]
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:338) ~[?:?]
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:382) ~[?:?]
at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) ~[?:?]
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) ~[?:?]
at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) ~[osgi.core-6.0.0.jar:?]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[osgi.core-6.0.0.jar:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.container.Module.start(Module.java:467) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402) ~[org.eclipse.osgi-3.12.100.jar:?]
at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1153) ~[?:?]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1036) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062) ~[?:?]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_272]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_272]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_272]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_272]
2020-12-09 21:56:32.128 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.20.2’ 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.