Tasmota on the Sonoff ifan02

This one was a bit of a challenge. The ifan02 uses relays and capacitors to do speed control just like the way the special pull switch does on dumb fans. The trouble is, I don’t know what about adding capacitance to some winding on a motor makes it go faster or slower. The fan I have uses 6.5uF capacitors and the sonoff comes with 2.5uF ones onboard so I have to change them to make it compatible. I think I got lucky with this one.

The switch in question

The main problem is this: the fan I have has one big monolithic capacitor that has three components in it, two of which get switched out for changing the speed and the other I think is the ‘run’ capacitor and is always connected to a special winding on the motor. I don’t have room to fit the ifan02 in the part of the fan where the switches are normally located, between the fan and the light. This means I need to put the module above the fan, in the ceiling. I also need to transplant 2/3 of the capacitor into the ifan02 because my fan uses different value capacitors than the ones onboard the ifan module. Luckily for me the 5uF of run capacitance is exactly double the 2.5uF capacitors in the ifan, so when I remove those to install the 6.5uF ones, I can make a 5uF capacitor from the leftovers and stuff it where the old one was.

I hope this makes sense to you, it sort of makes sense to me.

I started to puzzle out the pattern of adding capacitors and how many made what speed, but it turns out that it’s already done by defining your module as a SONOFF_IFAN02 in tasmota. There’s special code that handles different speeds and the light separately. Internally I’m not sure how it works, but there’s an RF remote that works in parallel with the network control of the fan and light. That remote takes a CR2025 battery, but will work with a CR2032 if you force it. You also have to re-pair the remote after changing the battery, there’s a switch on the back of the PCB for the remote you can use.

Initial puzzling

After it was online, it had to get integrated into homeassistant. I did that using the “Fan Control Entity Row” installed via HACS which is like an outside repository of integrations and UI components. You need almost the latest version of homeassistant to do that so once I got done updating and installing all the dependencies I had to figure out how to write the yaml component. After a lot of checking with different people’s solutions I ended up with this:

  • platform: mqtt name: “Upstairs Fan” command_topic: ‘cmnd/evan/inside/upstairs/fan/FanSpeed’ speed_command_topic: ‘cmnd/evan/inside/upstairs/fan/FanSpeed’ state_topic: ‘stat/evan/inside/upstairs/fan/RESULT’ speed_state_topic: ‘stat/evan/inside/upstairs/fan/RESULT’ state_value_template: > {% if value_json.FanSpeed is defined %} {% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %} {% else %} {% if states.fan.upstairs_fan.state == ‘off’ -%}0{%- elif states.fan.upstairs_fan.state == ‘on’ -%}4{%- endif %} {% endif %} speed_value_template: “{{ value_json.FanSpeed }}” availability_topic: ‘tele/evan/inside/upstairs/fan/LWT’ payload_off: “0” payload_on: “4” payload_low_speed: “1” payload_medium_speed: “2” payload_high_speed: “3” payload_available: Online payload_not_available: Offline speeds:
    • ‘off’
    • ‘low’
    • ‘medium’
    • ‘high’

There is one quirk I think I found, if you power cycle the module and then don’t command it to do anything the light will come on (good), the fan will come on (good?) but the fan speed seems to change and it doesn’t beep to indicate it’s doing so (not so good). I don’t know if this is some strange mode that the micro-controller (not the esp) onboard is in, or if I’m imagining it but I now always assert the fan speed shortly after power cycling the module.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: