Thanks again for the help on this! The device has been working great – flashed, fully installed in the fan, and integrated into Home Assistant. The feature set of the device works as expected, and was a great replacement for the failed Insteon FanLinc device.
There is one thing left to do, and I am unclear on how to do it. When I built and flashed the firmware, I did it from my personal Mac using a local install of esphome, with the device physically connected through the flasher to my Mac via USB-C. And, since the yaml file included Wi-Fi credentials, the device of course connected to the Wi-Fi network once it powered on. I was then able to adopt the device into Home Assistant and configured the ESPHome integration there for the device. But the device is not registered inside the ESPHome addon of Home Assistant, and so I can’t, for example, rebuild the firmware or update it. I feel like I should “adopt” it into the ESPHome instance inside of my Home Assistant machine, so I can flash it again in the future, etc. And I am unclear on how to do this…
The ESPHome device needs to be on the same network CIDR as the ESPhome plugin. This is because it uses broadcast to notify devices that it’s around.
So if your wifi is on a different network than your home assistant you will need to forward the broadcast packets. Then ESPHome interface will show it as a new device detected on the network.
Hey everyone. Looking to jump into getting ESPHome on my iFan04-L this weekend.
Looks like I have similar experience to @duerrd561 with doing Bluetooth proxies and a couple other simple things. Never flashed a device this way before, but I’ve picked up a few things that it seemed like I would need. Let me know if this all looks right:
From what I understand,I just need to run cables to that adapter from that group of 4 contacts on the iFan04 PCB? Does it need to be connected to the wall/fan at all or can I just disconnect it and it gets power from the USB adapter for flashing?
I haven’t installed ESPHome to a device with a yaml config like this before but I think I can figure that part out when I get to it.
The last question is around functionality. From what I’ve read it seems like everything from the original remote should just continue to work, and the only config changes that I’ll really need to make is just network info and device name. Is that right?
I don’t think you’ll need the header pins (2nd pic). I used some wires from your first pic and chopped off the end one end and used the socket end to connect to the usb2ttl. Then Soldered to the fan04 temporarily (it’s super fiddily).
The ifan04 has pads so you either have to use a pin clamp (or similar setup) or just solder on as i mentioned.
Don’t forget to set hte voltage of the USB 2 TTL adapter correctly.
My Home Assistant and ESPHome device are on the exact same Wi-Fi network subnet, and Home Assistant totally sees the device and has it all setup. It just isn’t showing up (i.e. to be “adopted”) in the ESPHome addon running on Home Assistant. Make sense?
Thanks! That was what I was looking for, and the thread you sent me to essentially has a solve/workaround which is to manually create the yaml file from my Mac’s esphome directory into the config/esphome/ directory on HA. This makes total sense, and I’m sure it would get me where I wanted.
One thing that I realize is probably a blocker on this specific device is the fact that I had to download a git clone of that rh1rich/esphome-ifan04 project and then I used the yaml from it to build this device’s firmware. And since that yaml file includes references to dependencies also in that git clone, I wouldn’t be able to get the exact same setup by just creating the yaml file on HA under config/esphome/ – I’d need the dependencies as well.
However I don’t think the ifan04-test.yaml file is designed to work for this inheritance use case. Someone would probably need to port it to a new file that could then be imported as a package. Am I thinking about this correctly?
This is what i’m using for my yaml config. I also SSHed into esphome and uploaded the ifan_remote.h file to the config directory that also stores the yaml .
I saw a number of people here had trouble getting the iFan04 into flash mode, how did you solve it? I’ve tried different USB cables, installing all recommend drivers for ESP and the adapter I’m using, but no luck.
When I plug just the adapter into my PC it recognizes it, but as soon as I try to connect the iFan04 nothing comes up. The LED comes on and it starts going into pairing mode if I just connect it to the adapter and plug it into my PC, but nothing happens when trying to hold the power button while giving it power.
From that single frontside picture the USB TTL device doesn’t have a regulator on it which means you might have missed that it is basically a requirement for this board. Sonoff Ifan04 - ESPHome working code - #61 by NonaSuomy
It finally worked after spending the entire afternoon trying to flash it. I tried with a Prolific TTL and later switched to a Arduino UNO as an adapter, both with an external bench power supply. In the end the problem was forgetting to hv the 3 grounds together.
#include "esphome.h"
using namespace esphome;
class MyCustomFloatOutput : public Component, public FloatOutput {
public:
int i2c_addr;
const int ch_addr[4] = {128, 129, 130, 131}; //AC dimmer channels
int channel; // from 0 to -3
int error;
bool debug;
void setup() override {
debug = 0; // set debug off/on
i2c_addr = 39; // set i2c address
Wire.begin();
Wire.beginTransmission(i2c_addr);
for (int i = 0; i < 4; i++){ // loop through all channels
Wire.write( ch_addr[i] );
Wire.write(100); //off
}
error = Wire.endTransmission();
if (debug == 1){log_err(error);} //debug
}
void write_state(float state) override { // state is the amount this output should be on, from 0.0 to 1.0
int value = state * 1024; // convert it to an integer first
value = map(value, 0, 1024, 100, 0); //convert to 0-100%
Wire.beginTransmission(i2c_addr);
Wire.write( ch_addr[channel] );
Wire.write(value);
Wire.endTransmission();
error = Wire.endTransmission();
if (debug == 1){log_err(error);}
}
void log_err(int error){
if (error==0){ ESP_LOGD ("custom", "I2C Transmissio: success");} // 0: success.
else if (error==1){ ESP_LOGD ("custom", "I2C Transmissio: data too long to fit in transmit buffer");} // 1: data too long to fit in transmit buffer.
else if (error==2){ ESP_LOGD("custom", "I2C Transmissio: received NACK on transmit of address");} // 2: received NACK on transmit of address.
else if (error==3){ ESP_LOGD("custom", "I2C Transmissio: received NACK on transmit of data");} // 3: received NACK on transmit of data.
else if (error==4){ ESP_LOGD("custom", "I2C Transmissio: other error");} // 4: other error.
else if (error==5){ ESP_LOGD("custom", "I2C Transmissio: timeout");} // 5: timeout
}
};
Hi everybody!
did somebody create a esphome custom component for the I2C MOSFET dimmer from krida?
that’s the arduino code:
would be nice to control the device with esp32 as I2C master
unfortunately no info from seller. little more guides and support couldn’t do so much harm especially regarding home assistant & esphome known as really very popular, more or less nothing to find …
@haydon So my Ifan04 has been functioning great with esphome since completing the process describe above here. And I’ve even got it managed through the esphome addon in HA now. So all good there.
I’m encountering an error when trying to use the device in HA Scenes, and wondered if you might have any suggestions. When I try to activate a Scene which has the Ifan04 fan set to a speed greater than 0 (i.e. on vs. off), the following error is thrown:
Preset mode is not valid, valid preset modes are: .
This wasn’t happening when I first set the device up in scenes and tested them. But it is happening now, and so the fan doesn’t run with the other fans I’m trying to synchronize it to.
Any thoughts on how I might further troubleshoot this?
I actually bought the one above previously for another project and have been unsuccessful with it. The regulator and CH340 is a key note thanks! I’d love to buy from Amazon instead of Ali to avoid the very long wait. I think this one has the regulator. Would someone be willing to confirm or deny my intuition here? Amazon.com: DSD TECH SH-U07B USB to TTL Adatper with CH340C Chip (2PCS) : Electronics