Sonoff IFan02 (Tasmota) MQTT Fan

hello Brother,
is there anyway to add the power state (keep) to ifan03 ?
we have a lot of power breakage so the light goes on in the middle of the night while fan turns off.
thank you

Has anyone worked out a way to hack a switch / rotary fan controller into the ifan02?

1 Like

Just looking to see if we can use the old rotary switch 4 pole 1 2 3 off as well
Thanks

simplest method would be to hack it into a remote so that each turn presses button on remote

hey I am looking at your info here but have no idea where to add it or anything sorry for sounding so stupid

What have you got so far and what is the end goal?

currently i have what ever comes up when HA auto-detects the device in MQTT my end goal is to have it on the interface and be able to use it in and the status in automatons

I have integrated the iFan02 but notice that when I stop the fan the speed attribute is not updated to “off”. It seems to remember the last speed setting that was used. Is there a way to set this attribute without writing an automation?

EDIT my workaround

- id: fansync
  alias: 'sync_fan_speed_when_off'
  hide_entity: True
  trigger:
    platform: state
    entity_id: fan.study_fan
    to: 'off'
  action:
    - service: python_script.set_state
      data_template:
        entity_id: fan.study_fan
        speed: 'off'

I got two iFan2s and found time to flash them only now. It seems the remote is broken on one. Red LED not working. The other one works fine but the remote does not turn the fan or switches on or off. How did you “pair” the remote? I tried removing and reinstalling battery but it doesn’t seem to work. Without remote, this is a no go :pensive:

Hi, Just flashed two iFan2 modules with just power coming from FTDI232. GND, Rx, Tx and 3.3 just the usual way and GND to TP16 when plugging the USB in. That’s it. Did not need to increase the power. Worked well!

I have 2 ifan02 as well, the remote is completely useless, batteries died with in a few days, and there range was completely useless, reason why they brought out the ifan03 with 433mhz remote.
The best thing I did was flash Esphome.
Tasmota was unpredictable.
I have a Hue Remote as the wall switch, but not happy with it, may look at the IKEA remote, or if I finally get the HA Switch Plate done one day.

You are saying that you have a working iFan03 running ESPHome and the remote works as well?

If so, do you mind either providing the code you used or a link to it?

No I said I have ifan02.
If you want the code for that happy to provide.

Oops, my bad. I could have sworn i saw ifan03. :crazy_face:

Never mind… :slightly_smiling_face:

Edit: you said “brought”. I thought you said “bought”…

That’s too bad. Esphome on the ifan03 would be nice to have.

well if you don’t care about the 433mhz remote its practically the same except the relays are just moved around and relay 1 is inverted
ifan02 - ifan03
image image

Quick question! In your setup, do you have other lights for your room? How to you keep the power running to Sonoff all the time. My bedroom only has fan lights and I need wall switch control also. But turning the switch off will turnoff the Sonoff. Any ideas to get that setup working?
Thank you.

I’ve noticed since a bunch of home assistant updates and the notes in the latest release I might need to update my current code:

fan:
  - platform: mqtt
    name: "Master Bedroom Fan"
    state_topic: "stat/sonoff-fan-master/RESULT"
    speed_state_topic: "stat/sonoff-fan-master/RESULT"
    state_value_template: >
        {% if value_json.FanSpeed is defined %}
          {% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}2{%- endif %}
        {% else %}
          {% if states.fan.master_bedroom_fan.state == 'off' -%}0{%- elif states.fan.master_bedroom_fan.state == 'on' -%}2{%- endif %}
        {% endif %}
    speed_value_template: "{{ value_json.FanSpeed }}"
    availability_topic: tele/sonoff-fan-master/LWT
    payload_available: Online
    payload_not_available: Offline
    speed_command_topic: "cmnd/sonoff-fan-master/FanSpeed"
#    payload_off_speed: "0"
    payload_low_speed: "1"
    payload_medium_speed: "2"
    payload_high_speed: "3"
    command_topic: "cmnd/sonoff-fan-master/FanSpeed"
    payload_off: "0"
    payload_on: "1"
    qos: 1
    retain: false
    speeds:
      - off
      - low
      - medium
      - high

Here is the write up https://www.home-assistant.io/blog/2020/02/05/release-105/

MQTT Fan - This fixes supported_features for an MQTT fan. Setting speed now requires only a speed command topic.

Before this change, only a speed state topic had to be set to support the setting of a speed. The speed state topic is not taken into account as it just decides if Home Assistant gets feedback for state and speed updates.

Likewise, setting oscillation now requires only an oscillation command topic. Before this change, only an oscillation state topic had to be set to support the setting of the oscillation. The oscillation state topic is not taken into account as it just decides if Home Assistant gets feedback for state and oscillation update.

(@springstan - #28680) (mqtt docs)

Yes I just put in 2 5mtr LED addressable on the ceiling and they both have around their beds as well. Both fans are in my kids rooms, no power switch on wall
I just have a Philips Hue Remote as the wall switch, the can also use Alexa or a 4 button 433mhz remote I setup to an RF Bridge. Also stuck a quick widget to toggle them on their phones through the Android app. Eventually I will put in a HA Switch plate.

1 Like

Hi All

If anyone is interested, This is my config for the sonnof iFan02 flashed with tasmota

There has been a few changes from when I first setup like POWER is now POWER1 and the TOPIC has changed in tasmota but anyway, below works perfect for me using the custom fan card installed via HACS

light:
- platform: mqtt
  name: "Bedroom1 Light"
  state_topic: "tele/bedroom1fan/STATE"
  value_template: "{{ value_json.POWER1 }}"
  command_topic: "cmnd/bedroom1fan/POWER1"
  availability_topic: "tele/bedroom1fan/LWT"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: false

fan:
- platform: mqtt
  name: "Bedroom1 Fan"
  command_topic: "cmnd/bedroom1fan/FanSpeed"
  speed_command_topic: "cmnd/bedroom1fan/FanSpeed"
  state_topic: "stat/bedroom1fan/RESULT"
  speed_state_topic: "stat/bedroom1fan/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.bedroom1fan.state == 'off' -%}0{%- elif states.fan.bedroom1fan.state == 'on' -%}4{%- endif %}
    {% endif %}
  speed_value_template: "{{ value_json.FanSpeed }}"
  availability_topic: tele/bedroom1fan/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'
1 Like

Thanks! :+1:t2: