[SOLVED] MQTT 2.4 and Tasmota

RasbPi 3 B+
openHABian 4.19.66
openHAB 2

Greetings everyone so I flashed Tasmota onto a NodeMCU v3, and hooked up a DTH11 (temp & humidity sensor) to it, which works fine, however I’m having trouble with the configuration for openHAB. I already had a look through some posts here, and the Tasmota article, and tried to configure it through both PaperUI and the config files, without much luck.

Comunity articles: Openhab binding tasmota

Tasmota article: https://tasmota.github.io/docs/#/integrations/openHAB

Config files:

//Things file
Bridge mqtt:broker:SenBroker "SenBroker" [ host="192.168.0.97", port=1883, secure=false, clientID="SenBroker"]
{
    Thing topic NodeMCU "NodeMCU" {
    Channels:
        Type number : Humidity    [stateTopic="cmnd/tasmota/", transformationPattern="JSONPATH:$.DHT11.Humidity"]
        Type number : Temperature [stateTopic="cmnd/tasmota/", transformationPattern="JSONPATH:$.DHT11.Temperature"]
      }
}
//Items file

//Lighting Relays
Switch channel1 "Living Room" <lightbulb> [ "Switchable" ] { gpio="pin:23 activelow:yes initialValue:high" }
Switch channel2 "Kitchen"     <lightbulb> [ "Switchable" ] { gpio="pin:24 activelow:yes initialValue:high" }
Switch channel3 "Bath"        <lightbulb> [ "Switchable" ] { gpio="pin:17 activelow:yes initialValue:high" }
Switch channel4 "Bedroom 1"   <lightbulb> [ "Switchable" ] { gpio="pin:27 activelow:yes initialValue:high" }
Switch channel5 "Bedroom 2"   <lightbulb> [ "Switchable" ] { gpio="pin:22 activelow:yes initialValue:high" }
Switch channel6 "Bedroom 3"   <lightbulb> [ "Switchable" ] { gpio="pin:16 activelow:yes initialValue:high" }
Switch channel7 "Garage"      <lightbulb> [ "Switchable" ] { gpio="pin:19 activelow:yes initialValue:high" }
Switch channel8 "Exterior"    <lightbulb> [ "Switchable" ] { gpio="pin:26 activelow:yes initialValue:high" }

//Ambient Sensors
Number  Temperature "Temperature [%s °C]" <temperature> {channel="mqtt:topic:SenBroker:NodeMCU:Temperature"}
Number  Humidity    "Humidity [%s %]"     <humidity>    {channel="mqtt:topic:SenBroker:NodeMCU:Humidity"}
sitemap home label="SmartHome"
{
  Frame label='Demo'
{

       Switch item=channel1
       Switch item=channel2
       Switch item=channel3
       Switch item=channel4
       Switch item=channel5
       Switch item=channel6
       Switch item=channel7
       Switch item=channel8
       Text item=Temperature
       Text item=Humidity

}
}

Can you post here how your MQTT messages from your device look like?

Also, make sure you have installed:

  • MQTT Binding (not the 1.x one) from PaperUI -> Addons -> Bindings tab
  • JSONPATH Transformation from PaperUI -> Addons -> Transformations tab

You mean in the Tasmota console?

Ye, I’ve done that right at the start. Double checked, both are installed

Take a peek at the mqtt messages yourself. Use something like mqttspy or mosquitto_sub. It just seems to me that your statetopic is wrong/incomplete. It is also worth checking that your nodemcu is actually posting to mqtt

Here you go,if this is what you meant.

04:30:41 MQT: Attempting connection...
04:30:41 MQT: Connected
04:30:41 MQT: tele/tasmota/LWT = Online (retained)
04:30:41 MQT: cmnd/tasmota/POWER = 
04:30:41 MQT: tele/tasmota/INFO1 = {"Module":"Generic","Version":"7.1.1(tasmota)","FallbackTopic":"cmnd/DVES_CB2169_fb/","GroupTopic":"cmnd/tasmotas/"}
04:30:41 MQT: tele/tasmota/INFO2 = {"WebServerMode":"Admin","Hostname":"tasmota-0361","IPAddress":"192.168.0.133"}
04:30:41 MQT: tele/tasmota/INFO3 = {"RestartReason":"External System"}
04:30:41 MQT: stat/tasmota/RESULT = {"POWER1":"ON"}
04:30:41 MQT: stat/tasmota/POWER1 = ON
04:30:41 MQT: stat/tasmota/RESULT = {"POWER2":"ON"}
04:30:41 MQT: stat/tasmota/POWER2 = ON
04:30:41 MQT: stat/tasmota/RESULT = {"POWER3":"OFF"}
04:30:41 MQT: stat/tasmota/POWER3 = OFF
04:30:41 MQT: stat/tasmota/RESULT = {"POWER4":"OFF"}
04:30:41 MQT: stat/tasmota/POWER4 = OFF
04:30:45 MQT: tele/tasmota/STATE = {"Time":"2019-12-11T04:30:45","Uptime":"0T00:00:14","UptimeSec":14,"Heap":29,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"ON","POWER2":"ON","POWER3":"OFF","POWER4":"OFF","Wifi":{"AP":1,"SSId":"TelstraADE449","BSSId":"10:13:31:AD:E4:49","Channel":11,"RSSI":68,"LinkCount":1,"Downtime":"0T00:00:08"}}
04:30:45 MQT: tele/tasmota/SENSOR = {"Time":"2019-12-11T04:30:45","Switch1":"ON","DHT11":{"Temperature":26.1,"Humidity":49.0},"TempUnit":"C"}
04:35:45 MQT: tele/tasmota/STATE = {"Time":"2019-12-11T04:35:45","Uptime":"0T00:05:14","UptimeSec":314,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER1":"ON","POWER2":"ON","POWER3":"OFF","POWER4":"OFF","Wifi":{"AP":1,"SSId":"TelstraADE449","BSSId":"10:13:31:AD:E4:49","Channel":11,"RSSI":68,"LinkCount":1,"Downtime":"0T00:00:08"}}
04:35:45 MQT: tele/tasmota/SENSOR = {"Time":"2019-12-11T04:35:45","Switch1":"ON","DHT11":{"Temperature":26.0,"Humidity":48.0},"TempUnit":"C"}

Ok, will try that.

stateTopic="tele/tasmota/SENSOR"
2 Likes
		Type switch :SSA05_1_Switch	"SSA05_1 Switch"		[ commandTopic="cmnd/ssa05_1/POWER", stateTopic="tele/ssa05_1/STATE", transformationPattern="JSONPATH:$.POWER" ]
		Type number :SSA05_1_Power	"SSA05_1 Power"			[ stateTopic="tele/ssa05_1/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
1 Like

As posted by @jcf6288 and @JimT you need a stateTopic starting with “tele” as you can see in your console log.
The device seems to have 4 relays (Power1 to 4), why don’t you switch them via MQTT ?

Note that for the openHAB 2.4 version of the MQTT binding when configured via things files you need to restart MQTT or the complete openHAB after a change to the things file for the MQTT things.

1 Like

Oh boy, works like a charm now, thanks guys. I though I’m supposed to use the topic in the info file I posted above. Don’t worry about the relays, there aren’t any physical ones connected to the module yet, was just playing around.

Coolio, please tick the solution post.
Thanks

1 Like