[SOLVED] MQTT 2.4 error when migrating from MQTT1

@David_Graeff One additional question. Everything works now but after a reboot I get the following line as one of the first in the log file

2019-01-21 18:27:39.852 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: host : You need to provide a hostname/IP!

Quite a bit further down in the log I get

2019-01-21 18:28:28.456 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'flukso'

Making me think all is fine,

but just to be sure: If I define the MQTT broker in the things file I don’t need anything else correct? or do I still need a mqttConnections.things file like described in https://www.openhab.org/addons/bindings/mqtt/

Because you are having an “mqtt.cfg” or “mqtt.config” file somewhere around in your openHAB directories. Please remove that file, there is apparently an invalid broker configured. And yes, that file gets auto generated if you click the wrong button (Services->MQTT system broker) in Paper UI.

But my mqtt.cfg is my MQTT1 configuration file, I can only delete that one once I have migrated all MQTT items from version 1 to the new version. As long as I run V1 next to the new version (during migration) I can’t (yet)

Nah, there is a second one, trust me. It might as well be called org.eclipse.smarthome.mqtt.cfg or so, but it is there.

The file I define my things in (my .things file) is called mqtt.things can that be an issue? The only other thing in my conf directories is mqtt-eventbus.cfg (but that doesn’t have anything but the explanation text which is all commented out)

@David_Graeff I now even removed the MQTT1 binding and below is list of files when doing find . -name mqtt

./conf/things/mqtt.things
./conf/services/mqtt.cfg
./conf/services/mqtt-eventbus.cfg
./userdata/mqtt
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt/0.10.0.oh240/org.eclipse.smarthome.binding.mqtt-0.10.0.oh240.jar
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt/0.10.0.oh240/org.eclipse.smarthome.binding.mqtt-0.10.0.oh240.jar.sha1
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt.generic
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt.generic/0.10.0.oh240/org.eclipse.smarthome.binding.mqtt.generic-0.10.0.oh240.jar
./userdata/tmp/mvn/org/eclipse/smarthome/binding/org.eclipse.smarthome.binding.mqtt.generic/0.10.0.oh240/org.eclipse.smarthome.binding.mqtt.generic-0.10.0.oh240.jar.sha1
./userdata/tmp/mvn/org/openhab/binding/org.openhab.binding.mqtt
./userdata/tmp/mvn/org/openhab/binding/org.openhab.binding.mqtt/1.13.0/org.openhab.binding.mqtt-1.13.0.jar
./userdata/tmp/mvn/org/openhab/binding/org.openhab.binding.mqtt/1.13.0/org.openhab.binding.mqtt-1.13.0.jar.sha1
./userdata/tmp/mvn/org/openhab/io/org.openhab.io.transport.mqtt
./userdata/tmp/mvn/org/openhab/io/org.openhab.io.transport.mqtt/1.13.0/org.openhab.io.transport.mqtt-1.13.0.jar
./userdata/tmp/mvn/org/openhab/io/org.openhab.io.transport.mqtt/1.13.0/org.openhab.io.transport.mqtt-1.13.0.jar.sha1
./userdata/config/org/eclipse/smarthome/mqttbroker.config
./userdata/config/org/openhab/mqtt-eventbus.config
./userdata/config/org/openhab/mqtt.config

The only one that I can see is the ./userdata/config/org/eclipse/smarthome/mqttbroker.config
this has one line

service.pid="org.eclipse.smarthome.mqttbroker"

But I don’t dare to delete that file as I’m 100% sure I didn’t create it so afraid of deleting system file that is needed.

Do you see anything that could cause the error

2019-01-21 18:27:39.852 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: host : You need to provide a hostname/IP!

That one.

This is just for the mqtt broker, not related to the mqtt binding.

I have the exact same situation and also had to update the REGEX. Although the syntax was correct, I only got NaN in Openhab. I had to restart my container to let it work, without changing anything else.
I agree this can be used in the example documentation, as the flukso config was one of the examples in the MQTT v1 docs

Jan, indeed I also need to restart the entire Openhab container every time I change something in the MQTT things file otherwise it doesn’t work or take the channel changes

@David_Graeff I need your guidance once more In migrating from MQTT1.

I have the following MQTT1 config that is working:

Switch NB_S1_O5_lichtbureauzij "Bureau zij" <light> (gLichtBeneden) [ "Lighting" ] {nikobus="09B9:5", mqtt=">[synology_old:openhab/light/bureauzij:state:*:${state}],<[synology_old:openhab/light/bureauzij/switch:command:default"}

I am converting this to

Bridge mqtt:broker:synology [ host="10.0.1.105", secure=false ]
    {
    Thing topic vthingsgarage {
       Channels:
         Type number : temperature "Temp garage" [ stateTopic="/sensor2/TEMP"]
         Type number : humidity "Humidity garage" [ stateTopic="/sensor2/HUM"]
        }
    Thing topic lights {
       Channels:
         Type switch : badkamer "Badkamer" [ stateTopic="/openhab/light/badkamer/switch", commandTopic="/openhab/light/badkamer"]
        }
    }

And this item configuration

Switch NB_S1_O2_lichtbadkamer "Badkamer" <light> (gLichtBeneden) [ "Lighting" ] { nikobus="09B9:2", channel="mqtt:topic:synology:lights:badkamer" }

It uses the same MQTT bridge as for the sensors and that is working, I also see the lights thing online in the PaperUI and I see it linked in the Paper UI to the button but it doesn’t do anything. I don’t see any MQTT message sent out in MQTT lense.

Something related when configuring a channel through the GUI there is a toggle “is command” how do you configure that in channel definition the .things file?
This is not the issue as I tried creating everything through the GUI and didn’t get any MQTT messages sent out either, so probably it’s something in the item configuration.

  1. You put an extra slash in front. For MQTT that is a totally different topic now.
  2. You have openhab/light/bureauzij vs openhab/light/badkamer. Intentionally?

Thanks that helps a lot, yes the bureauzij and badkamer was intentional, 2 different lights one controlled via MQTT1 the other via the 2.4 so I could see difference in MQTT lense for debugging pruposes.

With regards to the “is command” toggle in the channel config GUI, how do I add that ?

Honestly I forgot. I have added that to the documentation for OH 2.5, but because of all the code moving that happens at the moment, the documentation pages cannot be rebuild I assume.

You need to look at the latest README.md page of the binding in the code repository, I’m afraid.

Unfortunately, it is not possible to do that with the new binding.
Only the commandTopic sends outgoing messages
You will need another channel and a proxy item

Vincent no there is a toggle button in the GUI config to do that. To consider an incoming state topic as a command for the item. The question was just how to set that button through the .things file configuration.

Or am I wrong ?

No that’s the equivalent of:

<[synology_old:openhab/light/bureauzij/switch:command:default"}

The command on things file is:

postCommand=true

Why are you not using the GUI to define your things?

Because my 2 key bindings are OH1 binidngs, so untill those are migrated (which won’t happen as they are not actively maintained any more) I’m stuck to text configurations and I rather keep one single config method than mixing GUI and text.

But if I can’t replicate that MQTT1 command I really don’t see any reason for me to use the MQTT v2. Rather than just adding something in the item definition I not only need to add a channel but I need to add multiple channels or proxy items. That’s massive I have over 100 items to cover.