Issue of the topic:
I have spent countless hours trying to understand how the MQTT binding works and can’t seem to figure it out. I have read and re-read the wiki. I understand that MQTT has a broker and a client. I also understand that their have been two versions of the MQTT binding within openhab. I am using the Embedded Broker included in Openhab 2.5 and I am using the MQTT System Broker Connection. All settings here are default. My broker host is 127.0.0.1 for everything.
Do I have to create a rule to check the MQTT server? If so where do I put that?
I am trying to create a simple switch that will publish to MQTT.
MQTT : Topic : Value (correct me if this is the wrong structure)
Openhab / Relay / 1 / Value
020-02-01 01:22:29.301 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] -
Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@190e4 2e
from discovery topic +/+/$homie on broker mqtt:broker:1d93a54d but topic not registered at all. Check discovery logic!
2020-02-01 01:22:30.941 [ERROR] [org.openhab.binding.mqtt ] - bundle
org.openhab.binding.mqtt:2.5.1 (262)
[org.openhab.binding.mqtt.internal.discovery.MqttServiceDiscoveryService(268)] : The
activate method has thrown an exception
java.lang.IllegalArgumentException: ID segment 'Openhab MQTT Broker' contains invalid
characters. Each segment of the ID must match the pattern [A-Za-z0-9_-]*.
2020-01-31 18:40:19.056 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '127.0.0.1'. Next attempt in 60000ms
2020-01-31 18:40:19.908 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid 7e5f5fba-7429-4c2e-add5-0804fbfa11bb
2020-01-31 18:49:00.254 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: ID segment '127.0.0.1' contains invalid characters. Each segment of the ID must match the pattern [A-Za-z0-9_-]*.
2020-01-31 18:49:15.397 [WARN ] [.MqttBrokerConnectionServiceInstance] - Ignore existing broker connection configuration for: 127.0.0.1
Save yourself some time and uninstall this as it’s no longer supported.
You can install mosquitto broker from sudo openhabian-config tool then add the mqtt binding (2.x version) found in PaperUI under Bindings.
After that stop OH, clean the cache, restart OH and after fully restarted (watch the logs, frontail) you may need to reboot once or twice if you see lots of errors in logs.