Sonoff Tasmota with MQTT Binding 2.4 (using config files)

I’m using the .things file to define my mqtt things.
My broker is set up using the same syntax as yours. Can’t say if the localhost address and using no credentials is making the connection, but you should see that in the logs!
For the device things my working syntax is:

Thing topic sonoff_2_Thing "Light_2" @ "Sonoff" {....  

For the channels I have to state the broker as well, like:

String Sonoff2_Version "Sonoff2 Version: [%s]" <sonoff_basic> { channel="mqtt:topic:opusMQTT:sonoff_2_Thing:Version"}

I do dislike this “second” syntax (without the “:”) but that is another story!


Thank you for the tutorial using config files… would you mind posting a Sitemap for your example? I hope this will help me to finalize my config. With PaperUI it’s already working.

I see that error in the logs too. It did not have any effect on the Things so I had been ignoring it. However I have now edited my .things and .items files to follow the correct syntax that @opus posted and that error is now gone. Part of the change involved adding the broker name to the channel in the items file. I will edit the first post and correct the syntax there.

I copied the syntax from the MQTT Generic Thing documentation for my example. At the time it looked like “Thing mqtt:topic:mything” but now looks like “Thing topic mything”. I can confirm that the latter is correct.

I will add one to the first post in this thread.

Hey @max-e-moose, All

Thanks for the update. I just verified it and it works also in my case fine!
All error/warning messages gone and the all switches and temperature and humidity items work fine.

Again all the best for the new year and thanks for the help and all the work for this project!
Very impressive that different kind of syntax still ends up in a working functionality. I like if something works error tolerant!


Can this be promoted to the manual? This is absolutely a top post!

After trying myself clueless for 2 days I found this post and I got the MQTT upgrade issues solved in about 3 hours.

Go to the docs, scroll down and click the edit button :slight_smile:

This is mega, thank you!!!

Where can I find info on:

  1. Pre-defined sonoff group tags (in your example you have; Sonoff_S20, Sonoff_B1, Sonoff_POW, Sonoff_SC, Sonoff_RF), i.e. in the round brackets
  2. Pre-defined sonoff icon labels (in your example you have; sonoff_s20_uk, sonoff_b1, sonoff_pow, sonoff_sc, sonoff_rf), i.e. in the triangular brackets


After struggling a lot I will give this a try, thanks.
I might be wrong but shouldnt the line:

String GF_Sonoff_S20_Reachable "Reachable: [%s]" <contactable> (GF_Sonoff_S20) { channel="mqtt:topic:sonoffs20:reachable" }

be .String GF_Sonoff_S29_Reachable ..................{ channel="mqtt:topic:mosquitto:sonoffs20:reachable" }

Correct, but … See this Thread

1 Like

The group name can be set to any string you like. Setting groups is not necessary.
The used icons are most probably images or icons created by the user. I use a picture of a sonoff basic, the name is file name of the image/icon.

After you helped me here to get everything running, I wrote down my complete MQTT setup process here:
I hope its a help for someone:


You are not wrong. Missed that when editing. I’ll fix that, cheers.

As @opus correctly pointed out, the Sonoff group tags and icons are ones that I defined. You can find out more about custom icons here. A collection of the pre-defined OpenHAB icons can be found here.

1 Like

Continuing the discussion from Sonoff Tasmota with MQTT Binding 2.4 (using config files):

Uninstalling and re-installing the app fixed the issue, not rule related ; weird though ; thank you

Hello i used to have this rule send me broadcast notification whenever an item turns on or off, how can i make it work using mqtt 2.4 noting that mqtt action binding is no more available
Many thanks,

rule “Present”
Member of gDual changed or
Member of gSingle changed
if(previousState == NULL) return;
logInfo(“Sent”, “Test”)
sendBroadcastNotification( +" changed to " + triggeringItem.state.toString)

If you could post the topic and payload we could show you how to use the " mqttActions" as posted by @max-e-moose.
Although that should be possible for yourself.

Oliver, thanks for sharing your post.
For your future reference, and maybe somebody else who might use it, there’s a typo in your post:

sudo nano /etc/mosquitto/mosquitto.con
should read sudo nano /etc/mosquitto/mosquitto.conf (it’s missing a final F)

Thanks again for taking the time to write all that up.

Hey Alex! Thanks for the feedback. I just corrected it! Was a bit busy during the week.
But I am happy that it is a little help!

I also tried to change to the new 2.4 (2.5) mqtt binding. Nearly everything works because this helpful solution.
But i have problems with the sonoff RF bridge (newest Tasmota Firmware).

With mqtt 1 it was possible to send the RFKey with this command:

Switch Sw_it_licht_r88          "Hauptbüro"                  <light>            (G_sonoff,G_licht) ["Lighting"]    { mqtt=">[localbroker:cmnd/so_rfb_1/Backlog:command:ON:RfCode #004015], >[localbroker:cmnd/so_rfb_1/Backlog:command:OFF:RfCode #004014]" }
Switch Sw_it_licht_r11_west     "Buero West"                 <light>            (G_sonoff,G_licht) ["Lighting"]    { mqtt=">[localbroker:cmnd/so_rfb_1/Backlog:command:ON:RfCode #005015], >[localbroker:cmnd/so_rfb_1/Backlog:command:OFF:RfCode #005014]" }
Switch Sw_it_licht_r11_ost      "Buero Ost"                  <light>            (G_sonoff,G_licht) ["Lighting"]    { mqtt=">[localbroker:cmnd/so_rfb_1/Backlog:command:ON:RfCode #001015], >[localbroker:cmnd/so_rfb_1/Backlog:command:OFF:RfCode #001014]" }
Switch Sw_it_licht_r11_nacht    "Nachtlicht Büro"            <light>            (G_sonoff,G_licht) ["Lighting"]    { mqtt=">[localbroker:cmnd/so_rfb_1/Backlog:command:ON:RfCode #000415], >[localbroker:cmnd/so_rfb_1/Backlog:command:OFF:RfCode #000414]" }

I tried it with:

Type switch : button1       "Button 1"             [ stateTopic="stat/sonoff_rfb_1/RESULT", commandTopic="cmnd/sonoff_rfb_1/BACKLOG RfCode #000014" ]

But it do not work!

i also tried the “learned keys” but get some negativ entrys in the log:

2019-01-22 20:30:43.811 [nt.ItemStatePredictedEvent] - mqtt_topic_r88_brunnen_r88_aus predicted to become {"RfKey2":"Learned sent"}

==> /var/log/openhab2/openhab.log <==

2019-01-22 20:30:43.813 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfKey2":"Learned sent"}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfKey2":"Learned sent"}

2019-01-22 20:30:43.819 [WARN ] [l.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.RfKey1' in '{"RfKey2":"Learned sent"}'

2019-01-22 20:30:43.823 [WARN ] [eneric.internal.generic.ChannelState] - Command '{"RfKey2":"Learned sent"}' not supported by type 'OnOffValue': No enum constant org.eclipse.smarthome.core.library.types.OnOffType.{"RfKey2":"Learned sent"}

Can anybody help?

The mqtt topic is cmnd/so_rfb_1/Backlog according to your old configuration. A switch can only send “ON” and “OFF” to a topic, if you don’t define custom ON/OFF parameters. (see documentation)

That means actually: Send ON/OFF to this topic: cmnd/sonoff_rfb_1/BACKLOG RfCode #000014 which is not what you want :slight_smile:

You will need to change the channel type to String and create an item and a rule
Thing channel:

Type string : command       "Button 1"             [ commandTopic="cmnd/sonoff_rfb_1/Backlog" ]


String Sw_it_licht_command  { channel="mqtt:xxx:xxx:command }
Switch Sw_it_licht_r88          "Hauptbüro"                  <light>            (G_sonoff,G_licht) ["Lighting"] 
Switch Sw_it_licht_r11_west     "Buero West"                 <light>            (G_sonoff,G_licht) ["Lighting"]
Switch Sw_it_licht_r11_ost      "Buero Ost"                  <light>            (G_sonoff,G_licht) ["Lighting"]
Switch Sw_it_licht_r11_nacht    "Nachtlicht Büro"            <light>            (G_sonoff,G_licht) ["Lighting"]


rule "G_sonoff"
    Member of G_Sonoff received command
    if (receivedCommand == ON) {
        switch {
            case "Switch Sw_it_licht_r88" : Sw_it_licht_command.sendCommand("RfCode #004015")
            case "Switch Sw_it_licht_r11_west" : Sw_it_licht_command.sendCommand("RfCode #005015")
    } else {
        switch {
            case "Switch Sw_it_licht_r88" : Sw_it_licht_command.sendCommand("RfCode #004014")
            case "Switch Sw_it_licht_r11_west" : Sw_it_licht_command.sendCommand("RfCode #005014")

Quick question:
Can I run Mqtt 1.x and MQTT 2.4 Binding simultaneously?
That way I could migrate step by step.

Help is appreciated.