Sonoff Tasmota with MQTT Binding 2.4 (using config files)

some more info tried again today:

In the command line of the website on the sonoff itself:

22:45:08 CMD: status 2
22:45:08 MQT: stat/sonoffS20_1/STATUS2 = {“StatusFWR”:{“Version”:“6.5.0(release-sonoff)”,“BuildDateTime”:“2019.03.19 12:30:37”,“Boot”:31,“Core”:“2_3_0”,“SDK”:“1.5.3(aec24ac9)”}}

But when I query via MQTT fx:
either stat/sonoffS20_1/STATUS2 or stat/sonoffS20_1/STATUS 2 no answer :confused:

What is the console of the Sonoff (Outdoor, PowTV or sonoffS20_1?) showing when query for the firmware via the rule?
Do you have a logInfo in the line before the query that does show in the openHAB log?

But when I query via MQTT fx:
either stat/sonoffS20_1/STATUS2 or stat/sonoffS20_1/STATUS 2 no answer :confused:

to send a Command to a Tasmota device you should use CMND and not STAT. :wink:
try this one @MQTT fx:
cmnd/sonoffS20_1/STATUS 2

I tried all sorts of combinations. Answer is:
{“Command”:“Unknown”}

It’s an mqtt item, that does not show any information…? How can I see what / when / how the MQTT items are updated? What should your logInfo log?

From your previous post we understood you are using a device flashed with the tasmota software.
Using this device/software you can use it’s own webserver to check the messages received and sent when looking at the “Console” of the Tasmota device. Just put the IP address of the device into the address bar of a browser.
Using this console, you can check which commands are received. That way we can find out why YOUR comand send via a rule does not work.

Hey @opus thanks for YOUR continued support :wink:

I know what you asked me to do, I already experience the web console when I tried out the commands, see above. It seems that anything at the beginning is disregarded as it even reacts to cmnd/sonoffBlablabla/status 2 in the console…

Anyways, I don’t how to monitor the console as I don’t know when the MQTT item updates itself. So it would require me to monitor the console for an hour or so and see when the MQTT item fires. But as I cannot request the firmware information via MQTT.fx, I see no point to try around with the item… I really don’t know what I can do more, I guess I need to write to the developer to see if he’s got any clue…

Please try to subscribe to stat/sonoffS20_1/STATUS2 and use your rule to request the firmware, after that check trhe sonoff console for an output.

FYI I have the same problemn when trying to PUBLISH the command on MQTTfx as you observed ({“Command”:“Unknown”})

Edit: Found the problem on MQTTfx. When trying to publish cmnd/sonoffS20_1/STATUS 2 you need to put the cmnd/sonoffS20_1/STATUS into the publsih field and the “2” into the bigger field below:
MQTTfx_publish

Hey Opus that worked in MQTT.fx, thanks for the hint!

I tried a bit around and seems as follows:
You need to trigger a version request with:

cmnd/sonoffS20_1/STATUS 2

which I did via MQTT.fx and then I received with this item:

 String sonoffS20_2_Version "Sonoff fw version on public server [%s]"(gSwitch) {mqtt="<[broker:stat/sonoffS20_2/STATUS2:state:JSONPATH($.StatusFWR.Version)]" }

correctly the version.

So I guess we need to trigger the request to send out the version for every sonoff, could I be right?

That is correct and is the same as published in Tasmota documentation for openhab. See my link above. The rule in the maintenance example does just trigger openhab (or better the mqtt action) to send such a mqtt message

Let me add also 2 cents.
I think there are multiple solutions. I went through different topics and decided to put all together. I wrote a post here if somebody needs tutorial step by step how to configure Sonoff Bridge with OpenHAB with no rules could be helpful.

1 Like

Sorry , totally lost here, i’ve got a new OH2 installation with the EMBEDDED broker installed and working (tested with MQTT.fx)
I would try to add an SonOFF basic (flashed with Tasmota firmware)
If somebody can direct me in the wright direction , i would be very thankfull

Hello everyone,
i’m also switching to the new MQQT Binding 2.5.
in use:
openHAB 2.5.0-1 (release build)
latest openhabian freshly installed on RasPi 4

using mqqt config files and everything works.
But the following error from the log irritates me - what’s wrong here?

==> /var/log/openhab2/openhab.log <==
2019-12-20 13:19:12.310 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'mqtt.things', using it anyway:
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
Provide a thing type ID and a thing ID in this format:
 <thingTypeId> <thingId>
2019-12-20 13:19:12.326 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt.things'
==> /var/log/openhab2/events.log <==

here my mqtt.things file

Bridge mqtt:broker:MQTTBroker "MQTTBroker" [ host="127.0.0.1", port=1883, secure=false, clientID="openHAB", qos="1" ] 
{ 
    Thing mqtt:topic:KG_Keller2_Temp_05 "KG-Keller2-Temp-05" { 
        Channels:
            Type number : Temp      "Keller2 Temp"      [ stateTopic="/KG-Keller2-Temp-05/TempSensor/Temp" ]
            Type number : Luft      "Keller2 Luft"      [ stateTopic="/KG-Keller2-Temp-05/TempSensor/Luft" ]
            Type number : Uptime    "Keller2 Uptime"    [ stateTopic="/KG-Keller2-Temp-05/Laufzeit/Minuten" ]    
            Type number : WLAN      "Keller2 WLAN"      [ stateTopic="/KG-Keller2-Temp-05/WLAN/Signal" ]
            Type string : Update    "Keller2 Update"    [ stateTopic="/KG-Keller2-Temp-05/Systemzeit" ]
            Type switch : Reboot    "Keller2 Reboot"    [ commandTopic="/KG-Keller2-Temp-05/cmd", on="event,Reboot", off="" ]
    } 

    Thing mqtt:topic:KG_Roll2_06 "KG-Roll2-06" { 
        Channels:
            Type switch         : FlurEGDose1           "Steckdose Fenster"                 [ commandTopic="/KG-Roll2-06/mcpgpio/11", on="0", off="1" ]
            Type number         : Roll_Schiebe          "Schiebetüre"                       [ stateTopic="/KG-Roll2-06/Roll5" ]
            Type rollershutter  : Roll_SchiebeWinkel    "Schiebetür Winkel"                 [ commandTopic="/KG-Roll2-06/cmd", on="event,5WinkelUP", off="event,5WinkelDOWN", stop="" ]
    } 
}

thx

I also moved to 2.5 and my MQTT.things file was loaded with no comment in the logs.

Bridge mqtt:broker:opusMQTT [ host="192.168.178.50", secure=false, username="myUsername", password="MyPassword" , clientID="opusMQTTClient" ]
{
 Thing topic sonoff_1_Thing "Light_1" @ "Sonoff" {  
    Channels:
        Type switch : PowerSwitch  [ stateTopic="stat/sonoff_1/POWER" , commandTopic="cmnd/sonoff_1/POWER", on="ON", off="OFF" ]`  
        Type string : Version [stateTopic="stat/sonoff_1/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]
          }   
Thing topic sonoff_TH_Thing "Light_TH" @ "Sonoff" {
        Channels:            
Type switch : PowerSwitch  [ stateTopic="stat/sonoff_TH/POWER", commandTopic="cmnd/sonoff_TH/POWER", on="ON", off="OFF" ] 

Type string : Version [stateTopic="stat/sonoff_TH/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]            

Type number : Temperature [stateTopic="tele/sonoff_TH/SENSOR", transformationPattern="JSONPATH:$.AM2301.Temperature"]          
        Type number : Humidity [stateTopic="tele/sonoff_TH/SENSOR", transformationPattern="JSONPATH:$.AM2301.Humidity"]
                  }   
            }

Remove the colons “:” and “mqtt” from the Thing description. I.E.:
Thing topic KG_Keller2_Temp_05

Can’t see any issues in yours @opus. I’m also running the latest 2.5 and don’t have any of these errors in my logs.

Thanks for helping, but it was a typo in the post, my file is loading without any validation issues😊
Edited my post!

Gotcha. Did seem odd that you’d have that particular issue. :smile:

:gift_heart: thx its working

Apologies if this is a stupid question but can I use the things described in the OP with an embedded broker that I created with the Paper UI:

If so, what’s the syntax to put in the things file that works with this embedded broker?

After configuring the embedded broker, you next need to create a bridge to that broker in your things file like so:

Bridge mqtt:broker:bridge "MQTT Broker Bridge" [ host="localhost", port=1883, secure=false, username="username", password="S***tyPassword", clientID="openHAB2" ] 
{
    ...Things
}