The Tasmota Fan Controller I've been waiting for...

I've done several projects with the Sonoff iFan03 and various Martin Jerry dimmers to make my own fan controllers that work via Home Assistant while also following my rule of "never removing functionality while adding functionality" in a smart home.  The setup is challenging with replacing fan capacitors for 120vac based fans, dimmer rules, iFan rules, etc.  I've always been looking for a drop in fan controller that was not Zwave or Zigbee based.  Treatlife finally came out with a device that answers all of this and more!  

The Treatlife 2 in 1 Fan Controller and Light Dimmer is currently priced comparatively with other Zwave fan controllers that only have fan controls.  Available on Amazon Here.

A live stream is available showing the device -  View Live Stream on digiblurDIY

The switch will work with the Tuya Smartlife cloud app if you want to ride dangerously but as of this article if you attempt to use it via the Home Assistant Tuya integration, the dimmer and fan control entities will not show up.  So how do we control it?  We flash it with Tasmota of course!  Keep it all local control without the cloud! Unfortunately, at this time these devices are shipping with Tuya firmware that is blocking the current TuyaConvert exploit.  The switch will need to be flashed via the old school manual method.  Don't worry, this is fairly simple.  

Disconnect any power going to the device!  Remove the 4 screws and the face plate will come off.  There are no ribbon cables or wires to worry about.

The TYWE3S module containing the flash-able ESP8266 chip is wide out in the open.  There are multiple choices you can use to flash this chip with the 3v3 and GND headers.  Using a TTL USB adapter, you need to connect the following wires:  3v3 (do not use 5 volts!), Ground, RX, and TX.  GPIO 0 will also need to be attached to ground to enable flash mode on an ESP8266.  Instead of soldering, if you have a 3D printer you can also make a pogo pin jig as shown here and below.  Remember that RX goes TX and TX goes to RX on the USB TTL adapter.

Also, note you will need to put a jumper between NRESET and GND locations. This keeps the secondary TuyaMCU in a reset loop during the flashing of Tasmota.  Without this jumper the flashing process will not work.  

Once you've connected the necessary wires to your USB TTL device you can utilize Tasmotizer to flash the chip.  Additional information available on flashing Tuya devices can be found here in the Tasmota Wiki  Once flashed, disconnect GPIO 0 so it will boot up and add the Tasmota device to your network.

This TuyaMCU utilizes a baud rate of 115200 vs. previous dimmers and this requires Tasmota or later!  Tasmotizer should be flashing 8.4.0 or later at this time.

It's all down hill after this...  click the Console button on the Tasmota GUI of the fan switch.  Issue the following commands.  Take note it will restart during many of the commands, wait for the console to somewhat settle down before issuing the next one.  

module 54
so97 1
tuyamcu 11,1
tuyamcu 12,9
tuyamcu 21,10
ledtable 0
dimmerrange 10,1000
so59 1
so68 0

Add the following rule, this should be all on ONE line.

Rule1 on TuyaReceived#Data=55AA03070005030400010016 do publish2 stat/%topic%/speed 3,0 endon
      on TuyaReceived#Data=55AA03070005030400010117 do publish2 stat/%topic%/speed 3,1 endon
      on TuyaReceived#Data=55AA03070005030400010218 do publish2 stat/%topic%/speed 3,2 endon
      on TuyaReceived#Data=55AA03070005030400010319 do publish2 stat/%topic%/speed 3,3 endon

Enable the rule with the following

Rule1 1

You can then add the necessary MQTT configuration, device name, etc and it should be safe to disconnect the wires, reassemble the switch and install it on the wall, on mains AC power to the fan.  You might be asking at this point "how do I control the fan speed from the GUI?"  You will need to utilize the following commands to send the fan speeds on the console

TuyaSend4 3,0  (fan speed 1)
TuyaSend4 3,1  (fan speed 2)
TuyaSend4 3,2  (fan speed 3)
TuyaSend4 3,3  (fan speed 4)

You can also send those over MQTT if you like from various automations using cmnd/topic/tuyasend4 with a payload of 3,0 , etc.  

Currently, at this time, we can not use MQTT Auto Discovery with this switch.  And also, one other drawback, Home Assistant does not support more than 3 fan speeds.  (Feature request anyone?)  In this sample config below, I've dropped fan speed #1 due to this.

If you already have a "fan" and "light" section do not duplicate the sections.  Don't forget to change the "treatfan" topic to the MQTT topic configured in your switch MQTT section.

  - platformmqtt
    name"Bedroom Fan"
      - low
      - medium
      - high

  - platformmqtt
    name"Bedroom Light"
    value_template"{{ value_json.POWER2 }}"
    brightness_value_template"{{ value_json.Dimmer }}"

That's it!  Enjoy!  If you need help feel free to pop into Discord and ask for a hand.  

Links to products provided through the Amazon Affiliate program.


  1. I already have iFan03 in my ceiling fan, but never liked their remote control. Can I use this just as the switch on the wall that turns the fan/light on/off?

  2. Thank you for sharing this! I wish I knew how to decode the different commands you shared to know what they're doing. How could I go about converting this info into a template like

    1. No template needed for a TuyaMCU based switch. Just go to Configure Module then pick TuyaMCU. That's what the Module 54 command does.

  3. Any idea why home assistant Tuya integration doesn't pick it up natively?

    1. From what I've heard a few times their API server isn't really supported anymore, like how RGB bulbs don't have color wheels on them. It really wouldn't surprise me if one day it all just stopped working.

  4. Q: where did you get the bin file for When I pull latest as you have above, I get 8.3.1

    1. Off the Tasmota github page. "The Tasmota development codebase is checked every 1-2 hours for changes. If new commits have been merged and they compile successfuly, new binary files for every variant will be posted at (this web address can be used for OTA updates too). "

    2. I could not get the FW to update either at first. What I ended up doing was downloading tasmota.bin.gz and tasmota-minimal.bin.gz (make sure to use the .gz packed mapfile) to my computer from and then uploading them via the web interface. I had to upload the minimal binary first, then when that upgrade was complete I was able to upload the main binary. I did some reading and it seems to be related to binary size. Not sure why the method mentioned in this write-up works for some but not others.

    3. Great job on the sleuthing. It is supposed to flash minimal for you via OTA and then flash the full bin all automatically with the OTA upgrade option.

      Of course you can use the manual method. And just to document this anyone else reading, only flash the minimal version if the device is on your network with Tasmota already.

      If you are doing manual upgrades and get the buffer miscompare error which means not enough space. What I do is download the tasmota-lite.gz file. Flash that one. Then download the gz of the next one I need and it's just a little bit safer. Why? tasmota-lite contains the access point mode if something goes really weird in the middle. The minimal bin does not have access point mode.

  5. This worked GREAT. About 1 hour after I had the Jigs in hand, I had my TreatLife Fan control / dimmer on Tasmota and had it connected to Home Assistant.

    I had to gently rock the jig the first time to get it to connect, then it remained solid. My first flash was tasmota-lite. I could not upgrade within Tasmota to the full version (memory error) but then flashed from Tasmotizer again to full tasmota version

    1. Nice work! Tasmota should automatically handle the OTA 2 step flash to the development version. But yes, if you are using the manual BIN upload it's not a bad idea to send over lite first then the full tasmota.bin of the development version. With 8.3.x you can also use the .gz files too. I had an issue with Tasmotizer crashing if I tried to send the development build over first so I tried to keep it simple and all GUI for folks as much as possible.

  6. Follower all the steps in your procedure and after the manual flash the chip is stuck in a bootloop. See the log below.
    I flashed it with tasmota 8.4 .bin file .

    -------------- CUT HERE FOR EXCEPTION DECODER ---------------

    ets Jan 8 2013,rst cause:2, boot mode:(3,7)

    load 0x4010f000, len 3456, room 16
    tail 0
    chksum 0x84
    csum 0x84

    --------------- CUT HERE FOR EXCEPTION DECODER ---------------

    Exception (0):
    epc1=0x4026de40 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000


    ctx: sys
    sp: 3fffe5b0 end: 3fffffb0 offset: 0190
    3fffe740: 40105cec 40105ce9 00000000 00000000
    3fffe750: 400005e1 00000000 00000000 00000000
    3fffe760: 4026de40 00000033 00000020 00000000
    3fffe770: 40105cf2 04000102 00000000 00000001
    3fffe780: fbf8ffff 04000002 3feffe00 00000100
    3fffe790: 0000001e 00000018 04000102 40105cd4
    3fffe7a0: 3fffc100 3ffeed40 00000000 00000000

    1. The lite and minimal also give out the same error.

      I have tried the erase flash option using tasmotizer-1.1a but the same error log comes up.

    2. How are you powering and receiving this log? I have had this issue on other chips where the power supply wasn't enough to boot Tasmota via the USB flasher. Have you tried letting it boot via the mains unit itself with no wires connected?

    3. I am powering up via TTL USB adapter. Its getting 3.3V from the USB adapter. I have connected Teraterm and getting this log when the switch boots up. I don't think I can get the log with the main's connected.

      If i download the .gz file and extract the tasmota.bin file from it will it make any difference compared to downloading the tasmota.bin directly from web?

      Is there a way to force the .gz file on to the chip instead of the .bin file?

    4. @digiblurDIY you were correct. After I flashed with Tasmota lite and power up via mains everything seems to be working. Thanks For your help :)

    5. Awesome! And I do hope you upgraded off of lite to the regular bin. I don't recall if Lite supports TuyaMCU or not.

  7. Followed your instructions and they worked perfectly. Thank you for putting this together!

  8. This comment has been removed by the author.

  9. Hallo. I am struggling with wemos. I'm sending a signal from wemos 1 to wemos 2. wemos 2 turns on relay 1 and no 2. I guess it's the fault of the wifi. I have another question if it is possible to communicate with tasmota to tasmota without a router. If the routar network disappears, is it possible to connect to tasmota 1 and 2. Is it possible to send to several tasmota without a router, turn off the light. thank you.

  10. How could I use this switch to control 2 lights? a dimmable one and a regular one?
    Any advice greatly appreaciated.

  11. Struggling to get Tasmota on. I have soldered the wires onto the chip as you show, and connected everything to a USB serial adapter. When I use Tasmotizer, it says 'Failed to connect to ESP8266: Timed out waiting for packet header'. I know the module is getting power because it lights up, but I'm not sure what else to check. This is my first time trying to flash something with Tasmota, so I'm sure I'm missing something, just not sure what to check. Thanks so much for your help.


Post a Comment

Popular posts from this blog

Tuya Convert 2.3 Update | Flash Tuya Smartlife Devices | No Soldering! | Remove the cloud | Custom Firmware

How to use the Sonoff Zigbee Bridge with Home Assistant

Tuya Convert 2 - Flash Tuya Smartlife Devices - No Soldering - Remove the cloud with Tasmota ESPHome