Tasmotized Sonoff IFan03 and HASS
06 Jul, 2020
Sonoff IFan03 is a cheap little device for controlling a ceiling fan that you can manage over WiFi or 433MHz radio. Thankfully, it's very easy to flash open source Tasmota on it.
The case is not glued together, easy to open and put back together by bending the sides.
The pins necessary for flashing are marked, you can solder 2.45mm header and leave it, the case closes just fine afterwards. When you're ready to flash hold down the large white button that you use for RF pairing while you boot up and release after 5 seconds.
It doesn't have a spare GPIO for sensor(s). In most cases it's not worth it, but you can use RX/TX as GPIO if you turn serial logging off completely.
I used ft232r USB to serial UART interface with Tasmotizer flashing tool for Tasmota. Below the wiring.
HASS
Tasmota already has a template for IFan03 and you can communicate with Home Assistant over MQTT. In your configuration.yaml file you need to setup a template something like this.
fan:
- platform: mqtt
name: "ifan03"
state_topic: "ifan03-1/stat/RESULT"
speed_state_topic: "ifan03-1/stat/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined -%}
{% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}1{%- endif %}
{%- else -%}
{% if states.fan.ifan03.state == 'off' -%}0{%- elif states.fan.ifan03.state == 'on' -%}1{%- endif %}
{%- endif %}
speed_value_template: "{{ value_json.FanSpeed }}"
availability_topic: ifan03-1/tele/LWT
payload_available: Online
payload_not_available: Offline
speed_command_topic: "ifan03-1/cmnd/FanSpeed"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
command_topic: "ifan03-1/cmnd/FanSpeed"
payload_off: "0"
payload_on: "1"
qos: 1
speeds:
- low
- medium
- high
- platform: mqtt
name: "ifan03_light"
state_topic: "ifan03-1/tele/STATE"
value_template: "{{ value_json.POWER }}"
command_topic: "ifan03-1/cmnd/POWER"
availability_topic: "ifan03-1/tele/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
Make sure your MQTT topics correspond to your setup.
As of current version 0.112.3 Home Assistant's Lovelace UI doesn't really have a proper card to represent a fan control. The device is basically three switches (speeds), with default UI you can use horizontal stack card with three entity buttons inside.
cards:
- entity: fan.ifan03
name: Low
show_icon: true
show_name: true
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.ifan03
speed: 1
type: entity-button
- entity: fan.ifan03
name: Normal
show_icon: true
show_name: true
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.ifan03
speed: 2
type: entity-button
- entity: fan.ifan03
name: Fast
show_icon: true
show_name: true
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.ifan03
speed: 3
type: entity-button
- entity: fan.ifan03
icon: 'mdi:stop-circle-outline'
name: 'Off'
show_icon: true
show_name: true
tap_action:
action: call-service
service: fan.set_speed
service_data:
entity_id: fan.ifan03
speed: 0
type: entity-button
type: horizontal-stack
Which would correspond to something like this.
Or you can use a custom card I made for myself, downloadable from github.