Tasmota binding

I’m not sure what you mean by ‘frameware’ and I can’t tell if you’re being sarcastic or not


Personally, I though it would be nice to have a Tasmota auto-discovery going. So I built one. It supports Tasmota devices with an on/off state (Sonoff T1 for example) and with a dimmer (I use Armtronix Wifi dimmers as well as KingArt wifi dimmer wall panels). It needs to have a MQTT bridge configured, but that’s all it needs.

Of course, talk is cheap, so here’s a download: https://gofile.io/d/nA1WJi

Code is available too: https://github.com/DaanMeijer/openhab-addons/tree/tasmotamqttbinding/bundles/org.openhab.binding.mqtt.tasmota

1 Like

Or you could, as I just found out, use SetOption19 1 in the console of Tasmota, in order to enable HomeAssistant autodiscovery :sweat_smile:

Hi Daan, I figured that out already, True Setoption19 1 is required but Jinja transformation need to be activated too. Otherwise it isn´t running correctly.
Also I noticed with the latest OH update the autodiscovery is improved cause you will see now one thing with all the relaed channels automatically, before it was discovered with one thing per channel what was a bit confusing - now much better, and I decided to reconfigure all my tasmotas with the autodiscovery …

So far, I’ve had luck with switches but not so much with dimmers. I seem to be unable to link the discovered dimmer items (also, the dimmer value gets discovered, but no on/off toggle). So I currently still see merit for my new binding.

Hi Daan,
I also tried the “Setoption19 1” but i think this is polluting my network too much. So I tried to get your “Tasmota auto-discovery” up and running in my Openhab-3.1.0 installation.
For testing I used a local docker installation. But i was not successfull :frowning:
Has anyone already tried it with Openhab-3.1.0? If yes; what did you do to get it up and running?

I tried it with the following steps:

  • git download your branch (tasmotamqttbinding)
  • adapted the pom.xml (wrong name in dependency)
  • did a “mvn install package -DskipTests”
  • cp bundles/org.openhab.binding.mqtt.tasmota/target/org.openhab.binding.mqtt.tasmota-2.5.9-SNAPSHOT.jar /var/lib/docker/volumes/openhab_addons/_data/org.openhab.binding.mqtt.tasmota-2.5.9-SNAPSHOT.jar
  • then I get an error Message:
    “org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.mqtt.tasmota [262]
    Unresolved requirement: Import-Package: org.eclipse.smarthome.config.discovery”

2.5 binings won’t work on 3 and need migration.

Do you know how much effort a migration normally would be?

Yes I do :grinning:


Sounds doable … I’ll give it a try :slight_smile:

1 Like

Why do you think “SETOPTION19” will pollute your network? It only sends a few retained messages to your mqtt broker once. And that is all it does.

I am not really sure, but what I understood is that each of my (about 15) gateway-/PC-devices might trigger an UPNP-discovery request asking which devices are available and what they provide. And after this request each of the currently only 75 Tasmota Devices is answering with a discovery answer.
So before i reconfigured this (and others) it was not possible to use other 2.4Ghz Devices (Bluetooth and WIFI) in a stable way. I think this was due to generating too much traffic in the 2.4Ghz Wifi from my Tasmota devices.

But this is only one of the reasons why I am trying to get a dedicated Tasmota binding up and running.
I am hoping that one side effect of this will be saving some Network Bandwidth.

But the main points (i hope to get) are:

  • Complete recognition of all Tasmota Devices without having to handle all things and items myself.
  • Get more detailed information about the Tasmota-Devices (RSSI,Last Boot, …).
  • Less CPU power on the Raspberry-Pi needed. I hope that implementing the item parsing in Java should help here.
1 Like

I started to migrate your plugin to Openhab 3.1.0.
Shall we start a new thread for discussion about this specific tasmota binding?
There we could discuss what would be best to do to design and implement it.
Questions coming into my mind would be:

  • Shall we generate a separate thing for each kind of Tasmota device?
  • Would it be more appropriate to have one Thing named tasmotaDevice and have a lot of different channels which represent all possible values of a tasmota Device?
  • Discovery: What about publishing “cmnd/tasmotas/Status” “0” and then subscribing to “stat/#” this would immediately get all tasmota devices which have a default config?
  • Can we create Items from Java-code too?
1 Like

I’d love to have a github link when you’re ready!

My current way of adding Tasmota devices into openhab is by using a thing/item generator that I wrote. It uses a template for different type of things, e.g. one template for lightbulbs, another for smart plugs, another for switches, etc. It makes adding / modifying / deleting tasmota devices into openhab quick and easy.

I’m curious how it would be with a dedicated binding, in any case I’ll still use my generator, just change the template to generate the things according to the binding instead of pure mqtt. At the moment we have a lot of flexibility and freedom in how to create the things / items with mqtt.

Yes, currently I also have a script creating all I need. Starting from the configuration of all my tasmota devices, pushig this to the devices, (S20,Pow,4Ch,Touch,DHT11, RGB, Moisture, Status-LED, RFID, Buzzer, …)
These Tasmota configs also contain Rules to combine the single devices with each other. But my goal is that i want to reduce the usage of rules inside the tasmota devices and replace some of them with rules in openhab. But this is for really really later (realistic guess is probably in one or two years)

For openhab I also use this script to create config files template-like for things and Models (Items with group-Tags) for my things.
For now I have

  • Sonoff(S20, Pow, Touch)
  • WemosD1-Mini-with (DHT11,SHT)

I have one channel in the thing for (almost) each mqtt-json path.
Tasmota can provide the same information in different Json-Path. SO I had to create two things for these two Json-path possibilities. Which probably draws a lot of CPU Power on the Raspberry-PI.
Maybe I can combine this parsing into one single parse Request as soon as the Tasmota-binding is up and Running.

Models / Items:
And then i combine these things to Models by creating an item for each channels (sometimes multiple channels). And then combining the items into a model by using the appropriate group names.

These Models then are displayed with self defined widgets.

But this is still way at the beginning.


// Pow-1 Kueche 
  Thing topic Pow_1 "Pow Kueche (Pow-1)" @ "Küche" {
        Type switch : AvailabilityTopic     "Device Online State"            [ stateTopic="tele/Pow-1/LWT",         availabilityTopic="tele/Pow-1/LWT", 
        Type switch : Power          "Power"               [ stateTopic="stat/Pow-1/POWER", commandTopic="cmnd/Pow-1/POWER"  ]
        Type switch : Power_STATE    "Power"               [ stateTopic="tele/Pow-1/STATE",               transformationPattern="JSONPATH:$.POWER"           ]
    Type switch : Power_STATUS11 "Power"               [ stateTopic="stat/Pow-1/STATUS11",              transformationPattern="JSONPATH:$.StatusSTS.POWER" ]
    Type number : PowerLoad               "Power load"             [ unit="KWh", stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Power"          ]
    Type number : PowerReactive           "Power reactive"         [ unit="KWh", stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.ReactivePower"  ]
    Type number : Voltage                 "Voltage"                [ unit="V",   stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Voltage"        ]
    Type number : Current                 "Current"                [ unit="A",   stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Current"        ]
    Type number : Total                   "Total energy"           [ unit="KWh", stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Total"          ]
    Type string : TotalStartTime          "Total Start Time"       [               stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.TotalStartTime" ]
    Type number : TotalToday              "Total energy today"     [ unit="KWh", stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Today"          ]
    Type number : TotalYest               "Total energy yesterday" [ unit="KWh", stateTopic="tele/Pow-1/SENSOR",   transformationPattern="JSONPATH:$.ENERGY.Yesterday"      ]
    Type number : PowerLoad_STATUS10      "Power load"             [ unit="W",   stateTopic="stat/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Power"          ]
    Type number : Voltage_STATUS10        "Voltage"                [ unit="V",   stateTopic="stat/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Voltage"        ]
    Type number : Current_STATUS10        "Current"                [ unit="A",   stateTopic="stat/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Current"        ]
    Type number : Total_STATUS10          "Total energy"           [ unit="KWh", stateTopic="tele/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Total"          ]
    Type string : TotalStartTime_STATUS10 "Total Start Time"       [               stateTopic="tele/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.TotalStartTime" ]
    Type number : TotalToday_STATUS10     "Total energy today"     [ unit="KWh", stateTopic="stat/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Today"          ]
    Type number : TotalYest_STATUS10      "Total energy yesterday" [ unit="KWh", stateTopic="stat/Pow-1/STATUS10", transformationPattern="JSONPATH:$.StatusSNS.ENERGY.Yesterday"      ]
         // ============= General Status Things
         Type number : UptimeSec           "Uptime sec"            [ stateTopic="tele/Pow-1/STATE",      transformationPattern="JSONPATH:$.UptimeSec"           ]
         Type number : WifiChannel         "Wifi Channel"          [ stateTopic="tele/Pow-1/STATE",      transformationPattern="JSONPATH:$.Wifi.Channel"        ]
         Type number : WifiRssi            "RSSI"                  [ stateTopic="tele/Pow-1/HASS_STATE", transformationPattern="JSONPATH:$.RSSI"                ]
         Type number : WifiRssi_STATE      "Wifi RSSI"             [ stateTopic="tele/Pow-1/STATE",      transformationPattern="JSONPATH:$.Wifi.RSSI"           ]
         Type string : WifiSsid            "Wifi SSID"             [ stateTopic="tele/Pow-1/STATE",      transformationPattern="JSONPATH:$.Wifi.SSId"           ]
         Type string : IpAddress           "IP Address"            [ stateTopic="tele/Pow-1/HASS_STATE", transformationPattern="JSONPATH:$.IPAddress"           ]
         Type string : IpAddress_STATUS5   "IP Address"            [ stateTopic="stat/Pow-1/STATUS5",    transformationPattern="JSONPATH:$.StatusNET.IPAddress" ]
         Type string : FriendlyName        "FriendlyName"          [ stateTopic="stat/Pow-1/STATUS",     transformationPattern="JSONPATH:$.Status.FriendlyName" ]
         Type string : DeviceName          "DeviceName"            [ stateTopic="stat/Pow-1/STATUS",     transformationPattern="JSONPATH:$.Status.DeviceName" ]


// ========= Type Pow =========
Group  gType_Pow           "Group Type Pow"                                   <sonoff_Pow> (Sonoff_Pow)

 // Pow-1 Kueche 
 Group  gE_Pow_1                "Pow-1 Kueche Equipment"            <switch> (gType_Pow,Kueche) [ "Equipment" ]
 Switch Pow_1_Power             "Pow-1 Kueche"                     <switch>  (gPower, gType_Pow, gE_Pow_1)       ["Switch", "Switchable"                ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Power" }
 Number:Energy Pow_1_PowerLoad  "Pow-1 Kueche Power load [%.0f W]"  <energy>  (gEnergy, gType_Pow, gE_Pow_1)      ["Point",  "Measurement", "Power"    ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:PowerLoad" }
 Number Pow_1_Voltage           "Pow-1 Kueche Voltage [%.0f V]"     <voltage> (gVoltage, gType_Pow, gE_Pow_1)     ["Point",  "Measurement", "Voltage"  ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Voltage" }
 Number Pow_1_Current           "Pow-1 Kueche Current [%.2f A]"     <current> (gCurrent, gType_Pow, gE_Pow_1)     ["Point",  "Measurement", "Current"  ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Current" }
 String Pow_1_TotalStartTime    "Pow-1 Kueche Total Start Time"               (gType_Pow, gE_Pow_1)               ["Point",  "Measurement", "Energy"   ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Total" }
 Number:Energy Pow_1_Total      "Pow-1 Kueche Total [%.1f KWh]"     <energy>  (gEnergyTotal, gType_Pow, gE_Pow_1) ["Point",  "Measurement", "Energy"   ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Total" }
 Number:Energy Pow_1_TotalToday "Pow-1 Kueche Today [%.2f KWh]"     <energy>  (gEnergyTotal, gType_Pow, gE_Pow_1) ["Point",  "Measurement", "Energy"   ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:Total" }
 Number:Energy Pow_1_TotalYest  "Pow-1 Kueche Yesterday [%.2f KWh]" <energy>  (gEnergyYest, gType_Pow, gE_Pow_1)  ["Point",  "Measurement", "Energy"   ] {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:TotalYest" }
 Number Pow_1_EnergyCostToday  "Pow-1 Kueche Energy Cost (Estim by Today) [%.0f €]"  (gType_Pow, gE_Pow_1)      ["Point" ]
Number Pow_1_EnergyCostYest   "Pow-1 Kueche Energy Cost (Estim by Yesterday) [%.0f €]"  (gType_Pow, gE_Pow_1)      ["Point" ]

     // General Status Items
     Group  gE_Pow_1_Status             "Pow-1 Status Details Equipment"            ( gE_Pow_1 ) [ "Equipment" ]
     Switch  Pow_1_AvailabilityTopic    "Pow-1 Kueche Online State"            <switch>   (gReachable, gE_Pow_1_Status) ["Status"]   {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:AvailabilityTopic" }

     Number Pow_1_WifiRssi              "Pow-1 Kueche RSSI"                    <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:WifiRssi" }
     String Pow_1_WifiSsid              "Pow-1 Kueche Wifi SSID"               <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:WifiSsid" }         Number Pow_1_WifiChannel           "Pow-1 Kueche Wifi Channel"            <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:WifiChannel" }
     Number Pow_1_UptimeSec             "Pow-1 Kueche Uptime [%.1f sec]"       <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:UptimeSec" }
     String Pow_1_IpAddress             "Pow-1 Kueche IP Address"              <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:IpAddress" }
     String Pow_1_FriendlyName          "Pow-1 Kueche FriendlyName"            <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:FriendlyName" }
     String Pow_1_DeviceName            "Pow-1 Kueche DeviceName"              <status> (gStatus, gE_Pow_1_Status) ["Status"]    {
                                                                                                                    channel="mqtt:topic:mosquitto:Pow_1:DeviceName" }

widget tasmota_Pow:

  uid: tasmota_Pow
  tags: []
      - description: An item to control
        label: Item
        name: item
        required: false
        type: TEXT
    parameterGroups: []
  timestamp: Jan 13, 2021, 4:18:08 PM
  component: f7-card
    deactivated-title: =items[props.item + '_FriendlyName'].state
      - component: f7-card-content
            - component: f7-col
                  text-align: right
                  - component: oh-label-cell
                      trendItem: =props.item + "_PowerLoad"
                      action: analyzer
                      actionAnalyzerItems: =[props.item + "_PowerLoad"]
                      item: =props.item + "_PowerLoad"
                      title: =items[props.item + '_FriendlyName'].state
                      stateAsHeader: true
                      expandable: true
                  - component: widget:tasmota_status
                      item: =props.item
                  - component: oh-list-card
                      accordionList: true
                        - component: oh-label-item
                            item: =props.item + "_Current"
                            title: Current
                            action: analyzer
                            actionAnalyzerItems: =[props.item + "_Current"]
                        - component: oh-label-item
                            item: =props.item + "_Voltage"
                            title: Voltage
                            action: analyzer
                            actionAnalyzerItems: =[props.item + "_Voltage"]
                        - component: oh-label-item
                            item: =props.item + "_Total"
                            title: ∑
                        - component: oh-label-item
                            item: =props.item + "_TotalYest"
                            title: ∑ Yest
                        - component: oh-label-item
                            item: =props.item + "_TotalToday"
                            title: ∑ Today
                        - component: oh-label-item
                            item: =props.item + "_EnergyCostYest"
                            title: €/a from ∑-yest
                        - component: oh-label-item
                            item: =props.item + "_EnergyCostToday"
                            title: €/a from ∑-today

widget tasmota_Status:

uid: tasmota_status
  - nested
  - accordion
  - list
    - description: "The Base name of the Item (e.g.: DHT_1, Pow_0, ...)"
      label: Item
      name: item
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Jan 6, 2021, 4:37:52 PM
component: oh-list-card
  accordionList: true
    - component: oh-list-item
        title: ="Status"
        deactivated-title: ="Status "+props.item
        icon: oh:network
        badge: =(items[props.item + "_AvailabilityTopic"].state === "ON")?" OK ":"Offline"
        badgeColor: =(items[props.item + "_AvailabilityTopic"].state === "ON")?"green":"red"
        deactivated-after: =items[props.item + "_AvailabilityTopic"].state
          - component: oh-list-card
              noBorder: true
              noShadow: true
              outline: true
                - component: oh-list-item
                    item: =props.item + "_AvailabilityTopic"
                    title: AvailabilityTopic
                - component: oh-label-item
                    item: =props.item + "_WifiRssi"
                    title: RSSI
                - component: oh-label-item
                    item: =props.item + "_WifiSsid"
                    title: Ssid
                - component: oh-label-item
                    item: =props.item + "_Channel"
                    title: Channel
                - component: oh-label-item
                    item: =props.item + "_UptimeSec"
                    title: Uptime Sec
                - component: oh-label-item
                    item: =props.item + '_DeviceName'
                    title: Device Name
                - component: oh-label-item
                    item: =props.item + '_FriendlyName'
                    title: Friendly Name
                - component: oh-label-item
                    item: =props.item + "_IpAddress"
                    title: Ip Address
                - component: oh-list-item
                    title: Link to Device
                    listButton: true
                    action: url
                    actionUrl: ='http://' + items[props.item+"_IpAddress"].state +'/'

I’m interested in helping test as well, as I have 15-20 tasmota devices running, and have finally developed a good method of managing them.

One feature suggestion if it hasn’t been considered:

Some of my tasmotas have 8-10 sensors connected to them. When a sensor goes missing, the logs get flooded with missing sensors warnings (I think this is the MQTT binding)… it would be nice if instead there was a channel switch that could report the warning to an item instead.

Sure testers are welcome. But currently I am still at the basics to understand what I have to do to get a stable binding to work.
What I would also appreciate would be co-coders :slight_smile:

The current development is under:

If you really like; you can already have a look at it, but please only use a really separated setup. Since the discovery creates a lot of things in the inbox and you would need a script to remove them all.
At the current development state I am discovering tasmota devices by their mqtt messages:

  • tele//STATE
  • tele//STATUS
  • tasmota/discovery/#
    So after discovery you can (most likely) see all your tasmota devices. But The only thing you would see is the device itself and a lot of properties in this device. The only Devices which have working channels currently are Sonoff-Basic, Sonoff-Pow, Wemos-DHT11

I opened up a completely separated testing environment here. And as already said I would currently really recommend to do the same if someone wants to have a look at the current state.

My current setup for the start contains:

  • Sonoff-Pow
  • Sonoff-Basic
  • Wemos-D1Minit with DHT11
  • Wemos-D1Minit with DS1820

The Idea was to get those working as a start. And when those 4 are working I can add my other devices:

  • Sonoff-4CH
  • Sonoff S20
  • Sonoff S55
  • Sonoff Touch with 1 Switch
  • Sonoff Touch with 2 Switches
  • Sonoff Touch with 3 Switches
  • Sonoff RF-Shield (with RF-switches, RF-Movement, RF-Door Sensor, RF-DoorBell)
  • Wemos-D1-Mini with Button-Shield
  • Wemos-D1-Mini with Buzzer-Shield
  • Wemos-D1-Mini with IR-Shield
  • Wemos-D1-Mini with LED-Matrix-Shield
  • Wemos-D1-Mini with OLED Display-Shield
  • Wemos-D1-Mini with Relay-Shield
  • Wemos-D1-Mini with SHT-Shield
  • RGB-Strips
  • Water-Relay

Already well known open points with top Priority:

  • Get the Code cleaned up so that someone else can do things in the code too
  • Find Co-coders :slight_smile:
  • I think the binding triggers an additional Homematic subscribe. So I have to find where this is triggered and get rid of it.
  • Find where I put a date value instead of a Double (Temperature/Humidity/DewPoint sometimes gets a date instead of a Double)
  • I have a lot of ,messages with “although the handler was already disposed.” This probably leads to not updating the values when this message triggers.
  • Add more config options to tell the binding how to handle what it discovered
  • I have a lot of channels, but some channels are only for device management (RSSI,uptime, …) and others carry the real productive Values. So I want to introduce channel-groups to separate between config, sensors, actors.
  • Find a good naming scheme for all the channels (about 70 Channels per Device)
  • Adapt my widgets to the new channel names.

I’m also struggeling how to easly manage all devices. What’s your approach?
I flash them on my computer and via Termite I do all config with the backlog command. But afterwards all devices mostly remain untouched and never updated.

I have a perl script which can flash, update, configure all devices. To make bulk changes to all or part of the device the script does http requests to each device and sends the appropriate commands. So I can even reconfigure devices if they lose part of their config (which sadly happens once in a while)

1 Like

@wars LOL, Looking back, I think I exaggerated my ‘good method’ claim, but I’m mostly happy with how they work in OpenHAB.

Some photos might be an easier way to show. I integrated Tasmota, Ping and Unifi data, and some ‘constants’ that I still need to clean up.

Outlets and sensors are grouped so they can be linked to a location in the model without bringing all of the other telemetry data with them.

I need to figure out how to create a metadata entry for the IP address item so I can jump directly to the admin console to perform upgrades or look at the console.

I have not tried to use any auto-update scripts as, at the moment, most of mine have custom compiled options, but with the telemetry attributes linked to groups I can quickly see version numbers of all items. When I want to apply a setting change to all items, I just do that through MQTT.