When playing around with OH2 I had it working as well… that’s one of the reason why it’s bugging me so much.
When using sendCommand() I can see that the command is being retrieved by the item, but nothing is being sent to my queue…
So it looks like it’s a basic problem with the plugin… either not configured correctly or maybe some access issues.
It would be great if you could send me the files! According to the docs my Items should be correct, though.
I’ve also tested the configuration by adding a weird port value… and it looks like the mqtt binding reacts on that:
16:17:25.415 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:294 ] - Creating new client for 'tcp://192.168.1.111:118831' using id 'piq' and file store '/tmp/piq'
16:17:25.535 [ERROR] [.io.transport.mqtt.MqttService:114 ] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: MqttException
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:34) ~[na:na]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:553) ~[na:na]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_65]
Caused by: java.lang.IllegalArgumentException: port out of range:118831
at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143) ~[na:1.8.0_65]
at java.net.InetSocketAddress.<init>(InetSocketAddress.java:224) ~[na:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:64) ~[na:na]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:538) ~[na:na]
... 1 common frames omitted
I also get a timeout when I use a wrong host:
16:20:45.051 [ERROR] [.io.transport.mqtt.MqttService:114 ] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: MqttException
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:34) ~[na:na]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:553) ~[na:na]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_65]
Caused by: java.net.SocketTimeoutException: connect timed out
mqtt:mosquitto.url=tcp://openhab.zuhause.lan:1883
mqtt:mosquitto.clientId=openHAB
mqtt:mosquitto.user=username
mqtt:mosquitto.pwd=password
#mqtt:<broker>.qos=<qos>
#mqtt:<broker>.retain=<retain>
#mqtt:<broker>.async=<async>
#mqtt:<broker>.lwt=<last will definition>
Items:
Switch mqttSwitch {mqtt="<[mosquitto:haus/mqtttest/light:state:MAP(MqttSwitch.map)],>[mosquitto:haus/mqtttest/light:command:ON:1],>[mosquitto:haus/mqtttest/light:command:OFF:0]"}
Number mqttSwitchState {mqtt="<[mosquitto:haus/mqtttest/light:state:default]"}
String mqttTextS4 {mqtt="<[mosquitto:haus/test/TextS4:state:default"}
Sitemap:
Switch item=mqttSwitch label="MQTT Test Switch"
Text item=mqttSwitchState label="MQTT Test Switch State [%d]"
Text item=mqttTextS4 label="Text S4: [%s]"
If you change the mqttSwitch within the sitemap, the switch state changes within MQTT topic.
mqttSwitchState changes as well, because this one represents the state of the switch. This state is shown within the sitemap as text and cannot be change there.
The item mqttTextS4 shows the topic in the sitemap. If you change this string from another MQTT client, you can see this string within your sitemap…
Typo in your items file (unbalanced quotes). Try the openHAB Designer, or carefully scrutinize each and every line of your items file to look for syntax errors.