Control Tasmota flashed devices via MQTT

Thanks again and “the Bible” link is much appreciated. It is great to have more functionality in config files than the PaperUI exposes.

all this functionality is also covered by the UI.

Are you saying the PaperUI allows control of visibility?? I have not seen that.

Hi , I’m very new to openHab and have found this guide extremely useful so far. however I’m not quite sure how actually create the empty files within the command line, I assume its within the command line? any assistance or a dummies guide if you will for a newb like myself would be greatly appreciated. many thanks chris.


On the command line navigate to your specific folder, then

touch my_items.items

will create an empty Items file called my_items.

But that’s not particularly user friendly - how have you got openHAB setup? Do you have access through a normal file manager to your configuration files?

If you want to create and edit config files use an editor.

Thankyou very much, this is my first attempt at anything like this. until this point i had only used the paper UI and even installed the openHab o.s using the installation steps found on the sight. I don’t believe i have access through a normal file manager to my configuration files, however i did install putty last week and have managed to install the mosquito and check it works.

any help and tips are greatly appreciated.

Great tutorial, it helped me a lot. But I have a problem. I have a separate channel to set PulseTime but I would also like to get it’s state. If I publish cmnd/rega/PulseTime1 I get {"PulseTime1":{"Set":400,"Remaining":0}} from stat/rega/RESULT. But these /RESULT do not come regularly, as is the case with /STATE. How can I do this ?

You can change the TelePeriod from the default 300

In tasmota console enter

TelePeriod 10

I can’t provide a complete example at the moment, but I think you’ll have to create a Cron triggered rule which uses the MQTT action to publish an empty message to


You then need to setup a (new) Channel on your Thing which listens to


and probably uses REGEX to filter to make sure it includes the PulseTime1 keyword.

1 Like

@hafniumzinc Wow, I was not aware that it is possible to publish MQTT commands using rules. It opens tremendous possibilities, such as programming tasmota as if I were using its console. Thanks a lot, this was the solution.

Here is a simple OH3/DSL rule

  - id: "2"
      startlevel: 100
    type: core.SystemStartlevelTrigger
conditions: []
  - inputs: {}
    id: "1"
      type: application/vnd.openhab.dsl.rule
      script: |-
        val actions = getActions("mqtt","mqtt:broker:aveiro")
    type: script.ScriptAction

And here is the thing definition for a Sonoff 4CH Pro

UID: mqtt:topic:aveiro:sonoff_rega
label: Rega do Quintal
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:aveiro
  - id: zona1
    channelTypeUID: mqtt:switch
    label: Zona 1
    description: ""
      commandTopic: cmnd/rega/POWER1
      stateTopic: stat/rega/POWER1
  - id: zona2
    channelTypeUID: mqtt:switch
    label: Zona 2
    description: ""
      commandTopic: cmnd/rega/POWER2
      stateTopic: stat/rega/POWER2
  - id: zona3
    channelTypeUID: mqtt:switch
    label: Zona 3
    description: ""
      commandTopic: cmnd/rega/POWER3
      stateTopic: stat/rega/POWER3
  - id: zona4
    channelTypeUID: mqtt:switch
    label: Zona 4
    description: ""
      commandTopic: cmnd/rega/POWER4
      stateTopic: stat/rega/POWER4
  - id: zon1p
    channelTypeUID: mqtt:number
    label: Pulsetime 1
    description: null
      commandTopic: cmnd/rega/PulseTime1
      stateTopic: stat/rega/RESULT
      transformationPattern: REGEX:(.*PulseTime1.*)∩JSONPATH:$.PulseTime1.Set
  - id: zon2p
    channelTypeUID: mqtt:number
    label: Pulsetime 2
    description: null
      commandTopic: cmnd/rega/PulseTime2
      stateTopic: stat/rega/RESULT
      transformationPattern: REGEX:(.*PulseTime2.*)∩JSONPATH:$.PulseTime2.Set
  - id: zon3p
    channelTypeUID: mqtt:number
    label: Pulsetime 3
    description: null
      commandTopic: cmnd/rega/PulseTime3
      stateTopic: stat/rega/RESULT
      transformationPattern: REGEX:(.*PulseTime3.*)∩JSONPATH:$.PulseTime3.Set
  - id: zon4p
    channelTypeUID: mqtt:number
    label: Pulsetime 4
    description: null
      commandTopic: cmnd/rega/PulseTime4
      stateTopic: stat/rega/RESULT
      transformationPattern: REGEX:(.*PulseTime4.*)∩JSONPATH:$.PulseTime4.Set
1 Like

Instead of creating a separate thing to monitor the tele topic, you can also set the powerretain flag in Tasmota. This will send out the stat topic with the current value when Openhab connects.

In tasmota cosole enter:
powerretain 1

thanks for this awsome guide. Still I’m not able to turn my sonof switch from the basic UI.
I have a sonoff 4chpro properly configured, If I monitor it with mqttfx I can see an mqtt message when pushing every button. I use OH 2.4.0 and Mosquitto on the same raspberry. IN my sitemap wifi signal populate properly but the stiwtch item is not working, no topic sent to mqttfx, no error log in OH. can you help me debug the issue? how do I check mqtt logs?
thank you

things file:

Bridge mqtt:broker:mqtt "Broker MQTT"

Thing mqtt:topic:irrigazioneD "Sonoff pro aree 1,2,3,4" (mqtt:broker:mqtt) {
                Type switch : IrriPower1 "Interruttore area 1 (prato dx)" [

                Type switch : reachable "Reachable" [
                        stateTopic = "tele/irrigazioneD/LWT",

                Type number:rssi "RSSI" [

item file:

Switch Elettrovalvola1 "Irrigazione 1 (prato dx)"  { channel="mqtt:topic:irrigazioneD:POWER1" }
Switch Elettrovalvola1Reachable "Stato sonoff irrigazioneD" { channel="mqtt:topic:irrigazioneD:reachable" }
Number nBedroomSideLightRSSI "RSSI" { channel="mqtt:topic:irrigazioneD:rssi" }

sitemap file:

sitemap irrigazione label="Irrigazione" {
        Frame label="Sonoff D"{
        Switch item=Elettrovalvola1 label="Zona 1 - Prato DX"
        //Switch item=Elettrovalvola2 label="Zona 2 - Prato SX"
        //Switch item=Elettrovalvola3 label="Zona 3 - Prato studio"
        //Switch item=Elettrovalvola4 label="Zona 4 - Gocciolante alberi"

        Text item=Elettrovalvola1Reachable label="Stato del device: [%s]"
        Text item=nBedroomSideLightRSSI label="Connection quality [%d %%]" icon="qualityofservice"

You don’t seem to have any channel by that name (POWER1).
You did decide to name one IrriPower1 ?


right! that was one error, the other one was not adding user/password into sonoff mqtt config.
when I added the 4 channels I got more errors…sorry but I’ve upgrader OH from 2.4 to 2.5 and the system is not resuming…