Ifan04 with tasmota as actual fan?

Hi everybody,

I recently bought a couple if Sonoff iFan04-H (which actually show up as Sonoff iFan04-L) devices to control ceiling fans in my home. I already found this post and tried to configure things accordingly, but multiple options of template_fan have changed since then. I tried to adapt to it, but it did not work.

Below is a screenshot of how the device shows up in Home Assistant:

The first switch (Arbeitszimmer/Deckenfan) shows up as switch.arbeitszimmer_deckenfan. The other three switches just have names such as switch.mqtt_77dcba_rl_2. The don’t have a friendly_name at all. This is what they look like in the tasmota webUI:

On the left is what shows up as switch.arbeitszimmer_deckenfan (which is actually the light bulb connected to my ceiling fan); 0 does not show up in Home Assistant at all, then 1- 3 are the unnamed switches from above. They control the fan speed.

I have enabled setoption19 1 in tasmota so that the device would be automatically discovered by Home Assistant. It reports states like these

19:28:32.893 MQT: tele/tasmota_ifanaz00/HASS_STATE = {"Version":"10.1.0(tasmota)","BuildDateTime":"2021.12.08 14:47:39","Module or Template":"iFan04-L","RestartReason":"Software/System restart","Uptime":"0T10:49:51","Hostname":"tasmota-ifanaz00-7354","IPAddress":"10.0.20.62","RSSI":"90","Signal (dBm)":"-55","WiFi LinkCount":2,"WiFi Downtime":"0T00:00:26","MqttCount":12,"LoadAvg":19}

and

19:32:11.898 MQT: tele/tasmota_ifanaz00/STATE = {"Time":"1970-01-01T19:32:11","Uptime":"0T10:51:42","UptimeSec":39102,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":12,"POWER1":"OFF","FanSpeed":0,"Wifi":{"AP":1,"SSId":"","BSSId":"","Channel":1,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":2,"Downtime":"0T00:00:26"}}

I can control the fanspeed attribute from the tasmota console

19:33:01.899 CMD: fanspeed 1
19:33:01.907 MQT: stat/tasmota_ifanaz00/RESULT = {"FanSpeed":1}

However, I don’t know how to set this up as a single entity instead of having multiple -unnamed- switches. Also, turning off the device is not possible through Home Assistant at all! The unnamed switches don’t report their status back to Home Assistant, so they are always off (even when switched on via Home Assistant). Since the switch for 0 is missing, the only way is to turn one of the three unnamed switches off, which is impossible when they already are off (I can toggle them on, then off, but this seems to require very precise timing, otherwise won’t do anything at all).

I have seen a custom ESPHome solution for this device as well. However, I have no experience with including custom .h files in ESPHome, so I am kinda hesitant. If something went wrong, I’d have to manually flash the device, which would require me to (once again) uninstall the ceiling fan to get to the iFan-module. So while I’d try it for the next ceiling fan, I’d really like to keep tasmota on this device.

Can you recommend anything to make this work? Thank you in advance for your help :slight_smile:

1 Like

Here is a template for modern (2022) Ha install and Tasmota >= 11 with sonoff iFan04

- platform: mqtt
  name: "Master Bedroom"
  command_topic: "cmnd/master_bedroom_fan/FanSpeed"
  state_topic: "stat/master_bedroom_fan/RESULT"
  state_value_template: >
    {% if value_json.FanSpeed > 0 -%}1{% else -%}0{%- endif %}
  payload_off: "0"
  payload_on: "1"
  percentage_command_topic: "cmnd/master_bedroom_fan/FanSpeed"
  percentage_state_topic: "stat/master_bedroom_fan/RESULT"
  percentage_value_template: "{{ value_json.FanSpeed }}"
  speed_range_min:  1
  speed_range_max: 3
  availability_topic: tele/master_bedroom_fan/LWT
  payload_available: Online
  payload_not_available: Offline
3 Likes

Thank you so much! Works perfectly :slight_smile:

Hi,

Sorry but I can’t recognize this format as a template. Could you help me I don’t know how you run this settings in tasmota?

Thanks in advance.
Best regards.
Antonio.

Are you still using this? When I configure mqtt sensors in configuration.yaml now I get an error saying that’s not supported since 2022.12, I just got an ifan and ultimately want a “Low/Med/High/Off” button like the physical fan, but every solution seems to no longer work.

Yes, I do.

However, I don’t use mqtt for tasmota any longer, but rather the tasmota integration. If you use setoption19 0 (I do this by accessing the webUI of the tasmota device and go to console), it will be automatically discovered by Home Assistant, but via tasmota integration, not mqtt integration.

You might need to update the tasmota firmware, depending on what firmware you are currently running.

If this doesn’t work for you, either, you can switch back to mqtt autodiscovery by setting setoption19 1 on the tasmota device.

I was able to discover the device via the tasmota integration, but even with the right template, my IFAN04 just showed up with 2 switches, light on/off, and fan on/off. To run the commands and make buttons I made the following card in lovelace which works, but I don’t have state for the fans figured out yet (which isn’t critical in my case so it’s not a priority, I’m sure it could be done):

type: vertical-stack
title: Living Room
cards:
  - show_name: true
    show_icon: false
    type: button
    name: Ceiling Fan/Light
  - type: horizontal-stack
    cards:
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: toggle
        entity: light.sr66_ifan_03
        icon_height: 32px
        theme: Metro Purple
        icon: mdi:ceiling-fan-light
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: cmnd/SR66-IFAN-03/FanSpeed
            payload: '0'
        name: Fan Off
        icon: mdi:fan-remove
        icon_height: 32px
        theme: Metro Purple
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: cmnd/SR66-IFAN-03/FanSpeed
            payload: '1'
        name: Fan Low
        icon: mdi:fan-speed-1
        icon_height: 32px
        theme: Metro Purple
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: cmnd/SR66-IFAN-03/FanSpeed
            payload: '2'
        name: Fan Med
        icon: mdi:fan-speed-2
        icon_height: 32px
        theme: Metro Purple
      - show_name: false
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: cmnd/SR66-IFAN-03/FanSpeed
            payload: '3'
        name: Fan High
        icon: mdi:fan-speed-3
        icon_height: 32px
        theme: Metro Purple

It looks like this:

image

Home assistant is still using mqtt as disabling it on the tasmota device removes it from HA.