[OH3] Tasmota via MQTT Autodiscovery (Tasmota Version earlier than v12.1.1)

Update 2022/09/26 !!! Attention !!! With Tasmota version 12.x and later, HomeAssistant Autodiscovery is removed from Tasmota in favour of a new Tasmota-Autodiscovery. At the moment this is not compatible with OpenHAB.
It is still possible to add channels manually, but to use HomeAssistant Autodiscovery your only chance is to use an older Tasmota version up to 11.1.0

[OH3] Tasmota via MQTT Autodiscovery

This tutorial is meant to show how to setup openHAB3 and Tasmota with HomeAssistant Autodiscovery


This tutorial assumes you have

openHAB3 installed
MQTT up and running (if not, have a look at this great tutorial from hafniumzinc)
Tasmota installed on your device and already connected to Wifi

This tutorial will show you how to:

  1. checking pre-requisites
  2. prepare Tasmota-Settings for Autodiscovery
  3. activate Tasmota HomeAssistant Autodiscovery Feature
  4. create new Thing from Inbox
  5. create Items from Thing and add to semantic model

Im my example I used a Sonoff S20 with attached Temperature-Sensor, but this should work with all Tasmota-flashed devices.

Automatic discovery is currently supported for: - Buttons - Lights - Relays - Sensors - Switches - Fans

1. checking pre-requisites

To be able to use MQTT-Autodiscovery, you need the MQTT-Binding

And a connected MQTT Broker

And you need at least two transformations from Settings → Transformations

JSONPath and Jinja

2. prepare your Tasmota-Device for Autodiscovery

As far as I know autodiscovery was working since Tasmota version 6.x but it is highly recommended to use an actual Version. At the time this is written, Tasmota 9.2.0 is the latest and greatest. Your version can be found on the device mainpage of your Tasmota-Device

UPDATE 2022/09/26 From Tasmota 12.x and later HomeAssistant Autodiscovery is no longer supported by Tasmota. Please use an earlier version to be able to follow this tutorial until openHAB is updated to support the new Tasmota-Autodiscovery again.

First go to Configuration → Configure MQTT and insert your broker-settings

Be sure you use a unique Client-Name and Topic, not used by another MQTT-Device in your network.

Second go to Configuration → Configure Other , set the DeviceName and enable MQTT

3. activate Tasmota HomeAssistant Autodiscovery Feature

Autodiscovery-Activation has to be done via the Tasmota-Console, there is no WebUI for this

So please navigate back to you main-menu and select → Console

Now enter ‚SetOption19 1‘ and hit enter

Tasmota should respond with something like that

4. create new Thing from Inbox

Back in openHAB you should get a new discovered device automatically in your inbox

If you click on the Inbox Label, you get directly in the Inbox with the new device

Then clicking on the new autodiscovered device will ask you to create a new thing

You can edit your new Thing-Name and then proceed by clicking OK


Now the new Thing is created and you can find it in the list of Things to have a look at the details



from this view, you can add the new thing to your semantic model and create corresponding items

5. create Items from Thing and add to semantic model

In the channel-view click on ‘Add Equipment to Model’

(1) select where in your model the new equipment should be located

(2) + (3) configure the Relais and the Temperature-Sensor

Now the new Device is completely integrated

and can be used in the semantic model, too
For example you will get the Temperatur of the sensor in the automatically created properties-tab on the homepage, along with other Temperature-Items

or you can control the relais from the Equipment-TAB → Equipment


Hi Christian!

Thank you for a wery well written tutorial. I have been reading from different sources on how to connecting Tasmota using autodiscovery and your instructions were concise and clear using screenshots. It all just worked right away. This is good knowledge for future applications.

I do wounder why you added the two transformations as they were never explicitly used?

They are used behind the scenes by the binding to make the auto discovery work - a little hidden (undocumented?) gotcha which catches a few people out!


HomeAssistant Autodiscovery uses JSON-payload, so the JSON-Transformation is needed for that.

And the documentation for the JINJA-Binding states, that it is primary used to implement the HomeAssistant-Autodiscovery for OpenHAB

The main purpose of this transformer is the use in the home assistant discovery. Therfore not all features of the home assistant templating are supported. Basically on Processing incoming data

So both transformations are required to get a working autodiscovery.


Hello everyone,

I’m trying to add a Sonoff Basic with Tasmota to OH3

Tried it manually, the end result is I can turn it on from OH3, but turning off does not work. (Also, the state is not correctly displayed on the channel page - by default it always shows as off)

Tried it using the autodiscovery option in this thread - am noticing the same behavior, I’m able to turn it on using OH3 but not off.

Toggling it on/off from tasmota does display the correct state in OH3 events.log:
2021-01-17 22:17:34.232 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘SonoffBasic01_state’ changed from ON to OFF
2021-01-17 22:17:36.272 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘SonoffBasic01_state’ changed from OFF to ON
2021-01-17 22:17:38.878 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘SonoffBasic01_state’ changed from ON to OFF
2021-01-17 22:17:41.564 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘SonoffBasic01_state’ changed from OFF to ON
2021-01-17 22:17:43.842 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘SonoffBasic01_state’ changed from ON to OFF

Appreciate any advice. Thanks.

The config for the autodiscovered tasmota:
UID: mqtt:homeassistant_15845D:398e2a4556:15845D
label: Sonoff Basic 01
thingTypeUID: mqtt:homeassistant_15845D
- switch/15845D_RL_1
- sensor/15845D_status
basetopic: homeassistant
bridgeUID: mqtt:broker:398e2a4556
location: Living

Is this the same issue?

Essentially, try using a different device and/or browser…

1 Like

Indeed :confused:
Just tested on the android app and both on/off work.
This thread suggests to turn on:

  • Implicit user role for unauthenticated requests
    But I had to disable this for the android app to work (got solution from another thread)
    If I enable this, the browser then works fine, but android app stops working. I’ll try to check other threads for a solution on the android app.
    Thanks a lot.

Thanks for the tutorial
I have followed all the steps and its worked fine. The sonoff sv was discovered and I add it as a thing but I got only these two channels. what is the problem?

The discovered channels depend on your tasmota device. My Example-Device has a relay and a temperature-sensor attached. If you are using a normal sonoff-relay, you will only get state and status.

Seems ok for me.

I moved most of my things/items into Main UI when I upgraded from OH2 over the holidays, but I left the Tasmota things in text files and haven’t come back to them. I might take a stab at this later today.

From what I can see, it only requires you to do one more thing in Tasmota (SetOption19 1) that you don’t already have to do for manual configuration. So, I can see that this makes it easier to add more Tasmota devices in the future, particularly if you want to do everything in Main UI instead of text files. Are there any other benefits that I’m missing?

With Tuya switching new devices to Realtek chips that can’t be Tasmota-flashed, I’m considering stocking up on older Tuya gear before it goes out of stock. :wink:

But what about the other channels? like the wifi signal and also I have a contact switch connected to GPIO14 as switch 2.

Most propably they are not published unter the homeassistant-topic via tasmota.
I´m not sure if that is configurable.

Definitely, this is what I was thinking of because this what I found in the consol after restarting. But how to configure it to publish what I want.

00:00:00 CFG: Loaded from flash at F5, Count 143
00:00:00 QPC: Count 1
00:00:00 Project tasmota garage_opener Version 9.2.0(tasmota)-2_7_4_9(2020-12-21T15:03:40)
00:00:00 WIF: Connecting to AP1 NASSER Channel 4 BSSId  in mode 11n as garage_opener-0215...
00:00:03 WIF: Connected
00:00:04 HTP: Web server active on garage_opener-0215 with IP address
20:13:05 MQT: Attempting connection...
20:13:05 MQT: Connected
20:13:05 MQT: tele/garage_opener/LWT = Online (retained)
20:13:05 MQT: cmnd/garage_opener/POWER = 
20:13:05 MQT: tele/garage_opener/INFO1 = {"Module":"Sonoff SV","Version":"9.2.0(tasmota)","FallbackTopic":"cmnd/DVES_4B80D7_fb/","GroupTopic":"cmnd/sonoffs/"}
20:13:05 MQT: tele/garage_opener/INFO2 = {"WebServerMode":"Admin","Hostname":"garage_opener-0215","IPAddress":""}
20:13:05 MQT: tele/garage_opener/INFO3 = {"RestartReason":"Software/System restart"}
20:13:05 MQT: stat/garage_opener/RESULT = {"POWER":"OFF"}
20:13:05 MQT: stat/garage_opener/POWER = OFF (retained)
20:13:06 QPC: Reset
20:13:09 MQT: tele/garage_opener/STATE = {"Time":"2021-01-20T20:13:09","Uptime":"0T00:00:11","UptimeSec":11,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"NASSER","BSSId":"","Channel":4,"RSSI":74,"Signal":-63,"LinkCount":1,"Downtime":"0T00:00:05"}}
20:13:09 MQT: tele/garage_opener/SENSOR = {"Time":"2021-01-20T20:13:09","Switch2":"ON"}
20:13:14 MQT: homeassistant/switch/4B80D7_RL_1/config = {"name":"garage_opener_1","stat_t":"tele/garage_opener/STATE","avty_t":"tele/garage_opener/LWT","pl_avail":"Online","pl_not_avail":"Offline","cmd_t":"cmnd/garage_opener/POWER","val_tpl":"{{value_json.POWER}}","pl_off":"OFF","pl_on":"ON","uniq_id":"4B80D7_RL_1","dev":{"ids":["4B80D7"]}} (retained)
20:13:14 MQT: homeassistant/sensor/4B80D7_status/config = {"name":"garage_opener status","stat_t":"tele/garage_opener/HASS_STATE","avty_t":"tele/garage_opener/LWT","pl_avail":"Online","pl_not_avail":"Offline","json_attr_t":"tele/garage_opener/HASS_STATE","unit_of_meas":"%","val_tpl":"{{value_json['RSSI']}}","ic":"mdi:information-outline","uniq_id":"4B80D7_status","dev":{"ids":["4B80D7"],"name":"garage_opener","mdl":"Sonoff SV","sw":"9.2.0(tasmota)","mf":"Tasmota"}} (retained)

I´m not sure about the wifi, but some of your additional channels may getting exposed with some more SetOptions

1 Like

@Nasser how do you configured your module, that openhab auto creates a switch channel?
i use a D1 mini with a PIR sensor attached and do not get a “homeassistant/switch/*” topic from tasmota.

i have created a issue here: https://community.openhab.org/t/oh3-home-assistant-autodiscovery-with-d1-mini-tasmota-pir-as-switch1/114921/3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.