Hi community,
After migrating from MQTT1 to MQTT2.4 Binding, i think it might help to have a short howto.
Please note that i’m not using credentials, so i can only tell something about the basic broker configuration
Step1: Migrating the data from mqtt.cfg:
mqtt.cfg (I’ve only connetced to the broker using credentials)
mosquitto.url=tcp://localhost:1883
mosquitto.user=<some_secret_username>
mosquitto.pwd=<some_secret_password>
PaperUI (for MQTT 2.4)
Go to the inbox, add a new thing and select MQTT Thing Binding:
Next, you need to define a connection to your broker. Select MQTT broker and use the data that you also have used with the MQTT 1 binding
When you now save the thing, it should go to online (I’ve named my thing Mosquitto)
Ok now for the part that I was struggling a bit. The channel and items definition.
In MQTT1, i have had the following item definition for a sonoff device
Switch Sonoff4CH_Garden_Left_Relay1 "Relais 1" <poweroutlet> {mqtt=">[mosquitto:cmnd/Home/Garden/Sonoff/Left/power1:command:*:default], <[mosquitto:stat/Home/Garden/Sonoff/Left/POWER1:state:default]"}
Now, with MQTT 2.4, you need to do the following:
Step 1: Add a new thing in PaperUI and select a Generic MQTT Thing
Step 2: Give it a proper name (e.g. Sonoff4CH_Garden_Left) and select your previously defined broker
Step3: Go to the thing and add a new channel. For the Outlet in the example, a ON/OFF switch is sufficient:
A word for the channel ID and the Label: I tend to keep them the same which makes it easy to identify afterwards.
Step 3: Configure the MQTT topic for state and command and save this thing:
Step 4: You can now use the newly created channel within your item:
Switch Sonoff4CH_Garden_Left_Relay1 "Relais 1" <poweroutlet> {channel="mqtt:topic:08c64b74:Power1"}
And that’s it.
Sorry for the messed up layout here - i’m not really good at writing documentations