Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Image Added

Flashing

Connect RX -> TX | 3.3 -> 3.3 | TX -> RX | GND -> GND and connect TP16 to GND (as used in the TTL).

Press and hold the button while connecting to power.

This is an ESP 8285 in the iFan2.


Download and compile the Tasmota firmware:

git clone https://github.com/arendst/Tasmota.git

cd ./Tasmota/lib/

vi deployLibs.sh


Code Block
#!/bin/sh
rm -rf ~/Documents/Arduino/libraries/*

cp -R ./default/* ~/Documents/Arduino/libraries/.
cp -R ./lib_audio/* ~/Documents/Arduino/libraries/.
cp -R ./lib_basic/* ~/Documents/Arduino/libraries/.
cp -R ./lib_display/* ~/Documents/Arduino/libraries/.
cp -R ./lib_div/* ~/Documents/Arduino/libraries/.
cp -R ./lib_i2c/* ~/Documents/Arduino/libraries/.
cp -R ./lib_rf/* ~/Documents/Arduino/libraries/.
cp -R ./lib_ssl/* ~/Documents/Arduino/libraries/.
cp -R ./lib_ssl/* ~/Documents/Arduino/libraries/.


chmod +x deployLibs.sh

./deployLibs.sh


Open Arduino IDE

Image Added

Open tasmota project

Set board to ESP8285 and other settings, see below:

Image Added


With the iFan in flash mode, click Upload.

Image Added


Tasmota Commands


CmdCmndValueURL
Light OffPower0http://xxx/cm?cmnd=Power 0
Light OnPower1http://xxx/cm?cmnd=Power 1
Fan OffFanSpeed0http://xxx/cm?cmnd=FanSpeed 0
Low SpeedFanSpeed1http://xxx/cm?cmnd=FanSpeed 1
Med SpeedFanSpeed2http://xxx/cm?cmnd=FanSpeed 2
High SpeedFanSpeed3http://xxx/cm?cmnd=FanSpeed 3


Integration with Homebridge

Configure MQTT

Image Added


Using the mqttthing homebridge plugin, we configure our fan using the following:

Code Block
        {
            "accessory": "mqttthing",
            "type": "fan",
            "name": "fireplace-fan",
            "url": "http://192.168.1.50:1883",
            "username": "homebridge",
            "password": "pass",
            "topics": {
              "getOn": {
                "topic": "stat/fireplace-fan/RESULT",
                "apply": "return JSON.parse(message).FanSpeed > 0 ? true : false;"
              },
              "setOn": {
                "topic": "cmnd/fireplace-fan/FanSpeed",
                "apply": "return message ? '' : '0';"
              },
              "getRotationSpeed": {
                "topic": "stat/fireplace-fan/RESULT",
                "apply": "return Math.round(JSON.parse(message).FanSpeed * 33.3);"
              },
              "setRotationSpeed": {
                "topic": "cmnd/fireplace-fan/FanSpeed",
                "apply": "return Math.round(message / 33.3);"
              }
            },
            "confirmationPeriodms": 1000
        },


Order of Operations when Setting Rotation Speed

If we add some console.log statments in our apply function, we see that setting the rotation speed makes 2 calls. The first to setRotationSpeed and then to setOn.

Code Block
setRotationSpeed - mesage=73
setOn - mesage=true


After installing the iFan for use with my fireplace, I concluded that the fan level 1 was too low and decided to bypass it. This new configuration changes the fan such that it operates at 0% (off), 50%(fan level2) and 100%(fan level 3).

Code Block
{
            "accessory": "mqttthing",
            "type": "fan",
            "name": "fireplace-fan",
            "url": "http://192.168.1.50:1883",
            "username": "homebridge",
            "password": "pass",
            "topics": {
              "getOn": {
                "topic": "stat/fireplace-fan/RESULT",
                "apply": "return JSON.parse(message).FanSpeed > 0 ? true : false;"
              },
              "setOn": {
                "topic": "cmnd/fireplace-fan/FanSpeed",
                "apply": "return message ? '' : '0';"
              },
              "getRotationSpeed": {
                "topic": "stat/fireplace-fan/RESULT",
                "apply": "val=JSON.parse(message).FanSpeed; if(val==0)return '0'; if(val=='2') return '50'; if(val==3) return '100';"
              },
              "setRotationSpeed": {
                "topic": "cmnd/fireplace-fan/FanSpeed",
                "apply": "if(message >50) return 3; if(messag=e=0) return 0; return 2;"
              }
            },
            "confirmationPeriodms": 1000
        },


References