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 8.3.1.6 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.

fan:
  - platformmqtt
    name"Bedroom Fan"
    state_topic"stat/treatfan/POWER1"
    command_topic"cmnd/treatfan/POWER1"
    speed_state_topic"stat/treatfan/speed"
    speed_command_topic"cmnd/treatfan/tuyasend4"
    availability_topic"tele/treatfan/LWT"
    payload_available"Online"
    payload_not_available"Offline"    
    payload_on"ON"
    payload_off"OFF"
    payload_low_speed"3,1"
    payload_medium_speed"3,2"
    payload_high_speed"3,3"
    speeds:
      - low
      - medium
      - high

light:
  - platformmqtt
    name"Bedroom Light"
    state_topic"stat/treatfan/RESULT"
    value_template"{{ value_json.POWER2 }}"
    command_topic"cmnd/treatfan/POWER2"
    availability_topic"tele/treatfan/LWT"
    brightness_state_topic"stat/treatfan/RESULT"
    brightness_command_topic"cmnd/treatfan/Dimmer"
    brightness_scale100
    brightness_value_template"{{ value_json.Dimmer }}"
    payload_on"ON"
    payload_off"OFF"
    payload_available"Online"
    payload_not_available"Offline"



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.






Comments

  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?

    ReplyDelete
  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 https://templates.blakadder.com/treatlife_SS01.html?

    ReplyDelete
    Replies
    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.

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

    ReplyDelete
    Replies
    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. https://github.com/PaulAnnekov/tuyaha/issues/17

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

    ReplyDelete
    Replies
    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 http://thehackbox.org/tasmota/ (this web address can be used for OTA updates too). "

      Delete
    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 http://thehackbox.org/tasmota/ 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.

      Delete
    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.

      Delete
  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 8.3.1.7.

    ReplyDelete
    Replies
    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.

      Delete

Post a Comment

Popular posts from this blog

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

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

How to use the Sonoff Zigbee Bridge with Home Assistant