Ifan03 with tasmota to ha

I think it was two things.
First, I did a reinstall of the component and made sure to re-add it to my lovelace.
The URL in my lovelace raw config was incorrect as shown above, needed to just be:

url: /community_plugin/fan-control-entity-row/fan-control-entity-row.js

This seems obvious, since it is straight from the info on repository, but I confused it when it said I needed to change that to match where I saved the .js file, which for me was in /hassio/config/www/community/fan-control-entity-row. Ultimately, it just needed to be pointed at the community_plugin folder, which I don’t actually see anywhere via SAMBA. Weird.

So, now it works. Light turns on and off great, and the three fan speeds work. My ONLY issue is the “Off” button in the fan entity row does not work. If I click on the entity and set the state manually to off via the dropdown, that works, but now the Off button straight from the LoveLace UI.

Can’t figure that out yet :frowning:
Also, I use the emulated_hue component so I can use my Amazon Echo to turn things on or off. This works for the ceiling fan light, but it does not discover the ceiling fan so I can’t turn that on or change speeds via Amazon Echo, yet…

What is your configuration in HA to convert the fan controller switches (or are you using the MQTT topics) into a “fan.” entity?

Excuse my ignorance but not sure what your question means. I believe it uses MQTT, I have a “Ceiling Fan” entity that contains “off”, “low”, “medium”, and “high” in the JSON formatted “speed_list”.

My code is pretty much from the repo, I think. I don’t have anything that converts anything that I know of.

Code in configuration.yaml:

fan:

  • platform: mqtt
    name: “Bedroom Fan”
    command_topic: “cmnd/Bedroom_Fan/FanSpeed”
    speed_command_topic: “cmnd/Bedroom_Fan/FanSpeed”
    state_topic: “stat/Bedroom_Fan/RESULT”
    speed_state_topic: “stat/Bedroom_Fan/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.bedroom_fan.state == ‘off’ -%}0{%- elif states.fan.bedroom_fan.state == ‘on’ -%}2{%- endif %}
    {% endif %}
    speed_value_template: “{{ value_json.FanSpeed }}”
    availability_topic: tele/Bedroom_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”
      light:
  • platform: mqtt
    name: “Bedroom Fan Light”
    command_topic: “cmnd/Bedroom_Fan/power1”
    state_topic: “stat/Bedroom_Fan/POWER1”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: false

Then I use HACS for the card, and its configuration is:

entities:

  • entity: light.bedroom_fan_light
  • entity: fan.bedroom_fan
    type: ‘custom:fan-control-entity-row’
    show_header_toggle: false
    title: Bedroom
    type: entities

Maybe you were asking about my tasmota configuration instead? I am new to MQTT. I have used HA for over a year but never had much need for MQTT until this. Now I definitely want to use it more.

here is my config for an iFan03 using Tasmota:

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

use that and change to your topics/entity_ids as needed but don’t change anything having to do with the templates.

Do you remember which repo you got the above configuration from?

Only difference between ours (besides topics/entity_ids) was that I had quotations around all four speed listed at the end. I removed quotations from low, medium, high, leaving them around off. Restarted HA and no difference. Off on the fan control entity row card still does not work, but clicking the entity and using the “Speed” dropdown turns off fan.

I think I started with this but ended up reading in the community forums here mostly.

Wish I could get the off button to work.

I also need to swap out the capacitors. Haven’t hooked it up to a fan yet but I have a feeling since I am in US I will have speed issues as has been reported frequently with iFan_0x users.

that wasn’t the only difference.

here is your state value template:

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.bedroom_fan.state == ‘off’ -%}0{%- elif states.fan.bedroom_fan.state == ‘on’ -%}2{%- endif %}
  {% endif %}

and here is my state value template:

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.sunroom_fan.state == 'off' -%}0{%- elif states.fan.sunroom_fan.state == 'on' -%}4{%- endif %}
  {% endif %}

I think I remember needing to change the template to get the tasmota an to work. And I think that was what was needed to be changed.

try it and see if it works.

But TBH, what I would do is just copy/paste my whole config into yours and change the topics/entities to your own because I know for a fact my code works with the fan control row since I wrote it and I am using it right now with that code in a tasmotized iFan03. :wink:

If it doesn’t work then I guess it’s possible that something else has changed in the later tasmota versions. But we can’t know that until we are sure you have tried my exact working config to make sure it’s not an error on your end.

EDIT to add:

it’s also difficult to know if your code is completely correct because you didn’t format it correctly to display it properly. it would be helpful if you could edit your post to fix that. just put three back ticks (```) on a line above and a line below the code.

Never got back to you but I got this fixed last night by only changing the code above!

Thank you!!! You the man :slight_smile:

I also will start formatting shared code correctly from now on, thanks!

1 Like

Has anyone managed to load an ESP bin for the ifan03? I can’t seem to find anything related to ESP or the GPIOs of the 03 so I can even create my own yaml.

As far as I know there is no pre-canned ESPHome sketch you can load for the iFan03 yet.

And I asked a long time ago in the iFan03 thread in the Tasmota forum for the GPIO pinout (especially as it relates to the remote control) and I never got any responses.

Digging thru the Tasmota code I found the GPIO to control the relays for the different functions but it still leaves trying to figure out the remote functions.

Here is what I have so far:

sonoff_template.h - 

{ "Sonoff iFan02",   // Sonoff iFan02 (ESP8285)
     GPIO_KEY1,        // GPIO00 WIFI_KEY0 Virtual button 1 as feedback from RC
     GPIO_USER,        // GPIO01 ESP_TXD Serial RXD and Optional sensor
     0,                // GPIO02 ESP_LOG
     GPIO_USER,        // GPIO03 ESP_RXD Serial TXD and Optional sensor
     GPIO_REL3,        // GPIO04 WIFI_O2 Relay 3 (0 = Off, 1 = On) controlling the fan
     GPIO_REL2,        // GPIO05 WIFI_O1 Relay 2 (0 = Off, 1 = On) controlling the fan
     0, 0, 0,          // Flash connection
     GPIO_KEY2,        // GPIO09 WIFI_KEY1 Virtual button 2 as feedback from RC
     GPIO_KEY3,        // GPIO10 WIFI_KEY2 Virtual button 3 as feedback from RC
     0,                // Flash connection
     GPIO_REL1,        // GPIO12 WIFI_O0 Relay 1 (0 = Off, 1 = On) controlling the light
     GPIO_LED1_INV,    // GPIO13 WIFI_CHK Blue Led on PCA (0 = On, 1 = Off)
     GPIO_KEY4,        // GPIO14 WIFI_KEY3 Virtual button 4 as feedback from RC
     GPIO_REL4,        // GPIO15 WIFI_O3 Relay 4 (0 = Off, 1 = On) controlling the fan
     0, 0
  },

starts at line 2035  
{ "Sonoff iFan03",   // Sonoff iFan03 (ESP8285)
     GPIO_KEY1,        // GPIO00 WIFI_KEY0 Button 1
     GPIO_TXD,         // GPIO01 ESP_TXD Serial RXD connection to P0.5 of RF microcontroller
     0,                // GPIO02 ESP_LOG
     GPIO_RXD,         // GPIO03 ESP_RXD Serial TXD connection to P0.4 of RF microcontroller
     0,                // GPIO04 DEBUG_RX
     0,                // GPIO05 DEBUG_TX
                       // GPIO06 (SD_CLK   Flash)
                       // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
                       // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
     GPIO_REL1_INV,    // GPIO09 WIFI_O0 Relay 1 (0 = Off, 1 = On) controlling the light
     GPIO_BUZZER_INV,  // GPIO10 WIFI_O4 Buzzer (0 = Off, 1 = On)
                       // GPIO11 (SD_CMD   Flash)
     GPIO_REL3,        // GPIO12 WIFI_O2 Relay 3 (0 = Off, 1 = On) controlling the fan
     GPIO_LED1_INV,    // GPIO13 WIFI_CHK Blue Led on PCA (0 = On, 1 = Off) - Link and Power status
     GPIO_REL2,        // GPIO14 WIFI_O1 Relay 2 (0 = Off, 1 = On) controlling the fan
     GPIO_REL4,        // GPIO15 WIFI_O3 Relay 4 (0 = Off, 1 = On) controlling the fan
     0, 0
  }
  
   /* Fanspeed is controlled by relay 2, 3 and 4 as in Sonoff 4CH.
      000x = 0
      001x = 1
      011x = 2
      101x = 3 (ifan02) or 100x = 3 (ifan03)
   */

Hey guys. I have been researching and reading about this for the past 2 days and have made some progress but still having issues with the OFF “speed” or state.

I disabled MQTT HA auto config, and inserted the manual YAML into my config. I now have a working light. The fan speeds work except when I select off it doesn’t turn off. Also when I click the fan on/off slider it slides on for 2 seconds, then slides back off, but no change happens to actual ifan device. Here’s my config:

fan:
  - platform: mqtt  
    name: "Family Room Fan"
    command_topic: "cmnd/familyroomfan/FanSpeed"
    speed_command_topic: "cmnd/familyroomfan/FanSpeed"    
    state_topic: "stat/familyroomfan/RESULT"
    speed_state_topic: "stat/familyroomfan/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.family_room_fan.state == 'off' -%}0{%- elif states.fan.family_room_fan.state == 'on' -%}4{%- endif %}
      {% endif %}
    speed_value_template: "{{ value_json.FanSpeed }}"
    availability_topic: tele/familyroomfan/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
  - platform: mqtt   
    name: "Fan Light"
    command_topic: "cmnd/familyroomfan/power1"
    state_topic: "stat/familyroomfan/POWER1"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

I’m not sure if it’s copy/paste error but the code you posted has both the fan and the light under the “fan:” section.

Is that the way it is in your actual code?

Afternoon All,
I recently setup my ifan03, but oddly when i switch it off after a few minutes it comes back on at the medium speed…

my fan.yaml looks like this:

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

inside home assistant the fan looks like this:
image

the console of the ifan shows:

18:20:49 MQT: tele/ifan1/LWT = Online (retained)
18:20:49 MQT: cmnd/ifan1/POWER = 
18:23:29 MQT: stat/ifan1/RESULT = {"FanSpeed":2}
18:23:35 MQT: stat/ifan1/RESULT = {"FanSpeed":0}
18:23:50 MQT: stat/ifan1/RESULT = {"FanSpeed":2}
18:25:04 MQT: tele/ifan1/STATE = {"Time":"2020-05-21T18:25:04","Uptime":"0T21:37:15","UptimeSec":77835,"Heap":27,"SleepMode":"Dynamic","Sleep":100,"LoadAvg":9,"MqttCount":211,"POWER1":"OFF","FanSpeed":2,"Wifi":{"AP":1,"SSId":"Wan17","BSSId":"FC:EC:DA:A7:F6:45","Channel":11,"RSSI":96,"Signal":-52,"LinkCount":234,"Downtime":"0T00:05:48"}}
1 Like

I’ve subscribed to my mqtt via node red and i can see this:


however if i look at the console on the ifan i can see that it has picked up a speed of 2 from an mqtt message, this doesn’t seem to be appearing in my mqtt though…
image

EDIT: SORTED! I got to the bottom of the issue, one of my Motion Sensors was turning on the fan with the RF code! Just changed one of the jumpers on the sensor and it’s sorted!

Wow that’s pretty obscure.

Nice troubleshooting there!

Hello everyone

I think I have the same problem that other people here, but I don’t know if I didn’t find the answer or if so, it didn’t worked for me.
when I switch on the fan with the card, it’s only show in blue for a few seconds, it remains working but I souldn’t see that status in the card.
Here is my code

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

And this is my card

image

thnks in advance

the first obvious problem is that you jut copied my code for my fan and didn’t change the 'else" portion to your entity. You need to change the “sunroom_fan” to “tasmota_ifan03”

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.tasmota_ifan03.state == 'off' -%}0{%- elif states.fan.tasmota_ifan03.state == 'on' -%}4{%- endif %}
  {% endif %}

but if that doesn’t fix it then you will need to figure out if your mqtt topics and payloads are correct.

Can I ask how you are presenting your iFan03 to Alexa? I have it running via MQTT and your custom row for the UI now but I really want to have the voice commands working.

Thanks,
Jay

I use nabu casa for alexa voice commands.

ah I see you are using the home assistant cloud, thanks for the reply.

Jay

Does Alexa recognize ‘medium’ for you?