Add option to disable support for module Sonoff iFan at compile time

Add option to disable support for module Sonoff iFan at compile time (#6093)
This commit is contained in:
Theo Arends 2019-07-14 22:08:19 +02:00
parent a053a2cc4a
commit d77017fd74
8 changed files with 101 additions and 27 deletions

View File

@ -303,7 +303,15 @@
// #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
// #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code)
// -- Counter input -----------------------
// -- Optional modules ----------------------------
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
#define USE_TUYA_DIMMER // Add support for Tuya Serial Dimmer
#define TUYA_DIMMER_ID 0 // Default dimmer Id
#define USE_ARMTRONIX_DIMMERS // Add support for Armtronix Dimmers (+1k4 code)
#define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
//#define ROTARY_V1 // Add support for MI Desk Lamp
// -- Counter input -------------------------------
#define USE_COUNTER // Enable inputs as counter (+0k8 code)
// -- Internal Analog input -----------------------
@ -402,11 +410,6 @@
#define SDM630_SPEED 9600 // SDM630-Modbus RS485 serial speed (default: 9600 baud)
//#define USE_MP3_PLAYER // Use of the DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#define MP3_VOLUME 10 // Set the startup volume on init, the range can be 0..30(max)
#define USE_TUYA_DIMMER // Add support for Tuya Serial Dimmer
#define TUYA_DIMMER_ID 0 // Default dimmer Id
#define USE_ARMTRONIX_DIMMERS // Add support for Armtronix Dimmers (+1k4 code)
#define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
//#define ROTARY_V1 // Add support for MI Desk Lamp
//#define USE_AZ7798 // Add support for AZ-Instrument 7798 CO2 datalogger (+1k6 code)
//#define USE_PN532_HSU // Add support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
// #define USE_PN532_CAUSE_EVENTS // Cause event execution for PN532_UID= and PN532_DATA=[if defined] (+ 30 bytes code)

View File

@ -1632,6 +1632,7 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
// ShowSource(source);
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
blink_mask &= 1; // No blinking on the fan relays
Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller
@ -1639,6 +1640,7 @@ void ExecuteCommandPower(uint8_t device, uint8_t state, int source)
Settings.pulse_timer[2] = 0;
Settings.pulse_timer[3] = 0;
}
#endif // USE_SONOFF_IFAN
uint8_t publish_power = 1;
if ((POWER_OFF_NO_STATE == state) || (POWER_ON_NO_STATE == state)) {
@ -1783,7 +1785,9 @@ void PublishStatus(uint8_t payload)
if ((0 == payload) || (99 == payload)) {
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) { maxfn = 1; }
#endif // USE_SONOFF_IFAN
stemp[0] = '\0';
for (uint32_t i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%s%s\"%s\"" ), stemp, (i > 0 ? "," : ""), Settings.friendlyname[i]);
@ -1922,10 +1926,12 @@ void MqttShowState(void)
} else {
#endif
ResponseAppend_P(PSTR(",\"%s\":\"%s\""), GetPowerDevice(stemp1, i +1, sizeof(stemp1), Settings.flag.device_index_enable), GetStateText(bitRead(power, i)));
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
ResponseAppend_P(PSTR(",\"" D_CMND_FANSPEED "\":%d"), GetFanspeed());
break;
}
#endif // USE_SONOFF_IFAN
#ifdef USE_LIGHT
}
#endif
@ -2000,11 +2006,6 @@ void PerformEverySecond(void)
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
}
if ((4 == uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands
SetDevicePower(1, SRC_RETRY); // Sync with default power on state microcontroller being Light ON and Fan OFF
SetDevicePower(power, SRC_RETRY); // Set required power on state
}
if (seriallog_timer) {
seriallog_timer--;
if (!seriallog_timer) {

View File

@ -81,6 +81,16 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef CODE_IMAGE
#define CODE_IMAGE 3
// -- Optional modules -------------------------
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
#define USE_TUYA_DIMMER // Add support for Tuya Serial Dimmer
#ifndef TUYA_DIMMER_ID
#define TUYA_DIMMER_ID 0 // Default dimmer Id
#endif
//#define USE_ARMTRONIX_DIMMERS // Add support for Armtronix Dimmers (+1k4 code)
#define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
//#define ROTARY_V1 // Add support for MI Desk Lamp
#define USE_COUNTER // Enable counters
#undef USE_ADC_VCC // Add Analog input on selected devices
#define USE_DS18x20 // For more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
@ -137,11 +147,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy meter (+2k code)
#define USE_MP3_PLAYER // Use of the DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#define MP3_VOLUME 10 // Set the startup volume on init, the range can be 0..30(max)
#define USE_TUYA_DIMMER // Add support for Tuya Serial Dimmer
#ifndef TUYA_DIMMER_ID
#define TUYA_DIMMER_ID 0 // Default dimmer Id
#endif
#define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
//#define USE_AZ7798 // Add support for AZ-Instrument 7798 CO2 datalogger
#define USE_PN532_HSU // Add support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code)
@ -199,6 +204,16 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_TIMERS_WEB // Disable support for timer webpage
#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
#undef USE_RULES // Disable support for rules
// -- Optional modules -------------------------
//#ifndef USE_SONOFF_IFAN
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
//#endif
#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef ROTARY_V1 // Disable support for MI Desk Lamp
#undef USE_COUNTER // Disable counters
#undef USE_I2C // Disable all I2C sensors
#undef USE_SPI // Disable all SPI devices
@ -210,9 +225,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter
#undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy meter
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
#undef USE_PN532_HSU // Disable support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
#undef USE_PZEM004T // Disable PZEM004T energy sensor
@ -328,6 +340,14 @@ void KNX_CB_Action(message_t const &msg, void *arg);
//#undef USE_TIMERS_WEB // Disable support for timer webpage
//#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
//#undef USE_RULES // Disable support for rules
// -- Optional modules -------------------------
#define USE_SONOFF_IFAN // Add support for Sonoff iFan02 and iFan03 (+2k code)
//#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef ROTARY_V1 // Disable support for MI Desk Lamp
#undef USE_COUNTER // Disable counters
#undef USE_DS18x20 // Disable DS18x20 sensor
#undef USE_DS18x20_LEGACY // Disable DS18x20 sensor
@ -343,9 +363,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter
#undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy meter
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
//#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
#undef USE_PN532_HSU // Disable support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
#undef USE_PZEM004T // Disable PZEM004T energy sensor
@ -399,6 +416,14 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_RULES // Disable support for rules
#undef USE_SCRIPT // Disable support for script
#undef USE_LIGHT // Disable support for lights
// -- Optional modules -------------------------
#undef USE_SONOFF_IFAN // Disable support for Sonoff iFan02 and iFan03 (+2k code)
#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef ROTARY_V1 // Disable support for MI Desk Lamp
#undef USE_COUNTER // Disable counters
#undef USE_DS18x20 // Disable DS18x20 sensor
#undef USE_DS18x20_LEGACY // Disable DS18x20 sensor
@ -414,9 +439,6 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter
#undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy meter
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
#undef USE_TUYA_DIMMER // Disable support for Tuya Serial Dimmer
#undef USE_ARMTRONIX_DIMMERS // Disable support for Armtronix Dimmers (+1k4 code)
#undef USE_PS_16_DZ // Disable support for PS-16-DZ Dimmer and Sonoff L1 (+2k code)
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
#undef USE_PN532_HSU // Disable support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
#undef USE_PZEM004T // Disable PZEM004T energy sensor

View File

@ -669,8 +669,10 @@ const uint8_t kModuleNiceList[] PROGMEM = {
SONOFF_B1, // Sonoff Light Bulbs
SLAMPHER,
SONOFF_SC, // Sonoff Environmemtal Sensor
#ifdef USE_SONOFF_IFAN
SONOFF_IFAN02, // Sonoff Fan
SONOFF_IFAN03,
#endif
SONOFF_BRIDGE, // Sonoff Bridge
SONOFF_SV, // Sonoff Development Devices
SONOFF_DEV,

View File

@ -942,6 +942,7 @@ void HandleRoot(void)
#endif
WSContentSend_P(HTTP_TABLE100);
WSContentSend_P(PSTR("<tr>"));
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
WSContentSend_P(HTTP_DEVICE_CONTROL, 36, 1, D_BUTTON_TOGGLE, "");
for (uint32_t i = 0; i < MaxFanspeed(); i++) {
@ -949,11 +950,14 @@ void HandleRoot(void)
WSContentSend_P(HTTP_DEVICE_CONTROL, 16, i +2, stemp, "");
}
} else {
#endif // USE_SONOFF_IFAN
for (uint32_t idx = 1; idx <= devices_present; idx++) {
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx, (devices_present < 5) ? D_BUTTON_TOGGLE : "", (devices_present > 1) ? stemp : "");
}
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
WSContentSend_P(PSTR("</tr></table>"));
}
if (SONOFF_BRIDGE == my_module_type) {
@ -1007,6 +1011,7 @@ bool HandleRootStatusRefresh(void)
if (strlen(tmp)) {
ShowWebSource(SRC_WEBGUI);
uint8_t device = atoi(tmp);
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
if (device < 2) {
ExecuteCommandPower(1, POWER_TOGGLE, SRC_IGNORE);
@ -1015,8 +1020,11 @@ bool HandleRootStatusRefresh(void)
ExecuteCommand(svalue, SRC_WEBGUI);
}
} else {
#endif // USE_SONOFF_IFAN
ExecuteCommandPower(device, POWER_TOGGLE, SRC_IGNORE);
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
}
WebGetArg("d", tmp, sizeof(tmp)); // 0 - 100 Dimmer value
if (strlen(tmp)) {
@ -1042,17 +1050,21 @@ bool HandleRootStatusRefresh(void)
if (devices_present) {
WSContentSend_P(PSTR("{t}<tr>"));
uint8_t fsize = (devices_present < 5) ? 70 - (devices_present * 8) : 32;
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) {
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(power, 0)));
uint8_t fanspeed = GetFanspeed();
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0));
} else {
#endif // USE_SONOFF_IFAN
for (uint32_t idx = 1; idx <= devices_present; idx++) {
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, idx -1));
WSContentSend_P(HTTP_DEVICE_STATE, 100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue);
}
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
WSContentSend_P(PSTR("</tr></table>"));
}
WSContentEnd();
@ -1573,7 +1585,9 @@ void HandleOtherConfiguration(void)
WSContentSend_P(HTTP_FORM_OTHER, stemp, (USER_MODULE == Settings.module) ? " checked disabled" : "", (Settings.flag.mqtt_enabled) ? " checked" : "");
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) { maxfn = 1; }
#endif // USE_SONOFF_IFAN
for (uint32_t i = 0; i < maxfn; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), i +1);
WSContentSend_P(PSTR("<b>" D_FRIENDLY_NAME " %d</b> (" FRIENDLY_NAME "%s)<br><input id='a%d' placeholder='" FRIENDLY_NAME "%s' value='%s'><p></p>"),
@ -1752,7 +1766,9 @@ void HandleInformation(void)
WSContentSend_P(PSTR("}1" D_BOOT_COUNT "}2%d"), Settings.bootcount);
WSContentSend_P(PSTR("}1" D_RESTART_REASON "}2%s"), GetResetReason().c_str());
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) { maxfn = 1; }
#endif // USE_SONOFF_IFAN
for (uint32_t i = 0; i < maxfn; i++) {
WSContentSend_P(PSTR("}1" D_FRIENDLY_NAME " %d}2%s"), i +1, Settings.friendlyname[i]);
}

View File

@ -309,6 +309,7 @@ void MqttPublishPowerState(uint8_t device)
if ((device < 1) || (device > devices_present)) { device = 1; }
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan() && (device > 1)) {
if (GetFanspeed() < MaxFanspeed()) { // 4 occurs when fanspeed is 3 and RC button 2 is pressed
#ifdef USE_DOMOTICZ
@ -320,6 +321,7 @@ void MqttPublishPowerState(uint8_t device)
MqttPublish(stopic);
}
} else {
#endif // USE_SONOFF_IFAN
GetPowerDevice(scommand, device, sizeof(scommand), Settings.flag.device_index_enable);
GetTopic_P(stopic, STAT, mqtt_topic, (Settings.flag.mqtt_response) ? scommand : S_RSLT_RESULT);
Response_P(S_JSON_COMMAND_SVALUE, scommand, GetStateText(bitRead(power, device -1)));
@ -328,14 +330,18 @@ void MqttPublishPowerState(uint8_t device)
GetTopic_P(stopic, STAT, mqtt_topic, scommand);
Response_P(GetStateText(bitRead(power, device -1)));
MqttPublish(stopic, Settings.flag.mqtt_power_retain);
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
}
void MqttPublishAllPowerState()
{
for (uint32_t i = 1; i <= devices_present; i++) {
MqttPublishPowerState(i);
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan()) { break; } // Report status of light relay only
#endif // USE_SONOFF_IFAN
}
}

View File

@ -74,6 +74,7 @@ int DomoticzRssiQuality(void)
return WifiGetRssiAsQuality(WiFi.RSSI()) / 10;
}
#ifdef USE_SONOFF_IFAN
void MqttPublishDomoticzFanState()
{
if (Settings.flag.mqtt_enabled && Settings.domoticz_relay_idx[1]) {
@ -95,21 +96,26 @@ void DomoticzUpdateFanState()
}
domoticz_update_flag = 1;
}
#endif // USE_SONOFF_IFAN
void MqttPublishDomoticzPowerState(uint8_t device)
{
if (Settings.flag.mqtt_enabled) {
if ((device < 1) || (device > devices_present)) { device = 1; }
if (Settings.domoticz_relay_idx[device -1]) {
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan() && (device > 1)) {
// Fan handled by MqttPublishDomoticzFanState
} else {
#endif // USE_SONOFF_IFAN
char svalue[8]; // Dimmer value
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), Settings.light_dimmer);
Response_P(DOMOTICZ_MESSAGE, (int)Settings.domoticz_relay_idx[device -1], (power & (1 << (device -1))) ? 1 : 0, (light_type) ? svalue : "", DomoticzBatteryQuality(), DomoticzRssiQuality());
MqttPublish(domoticz_in_topic);
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
}
}
}
@ -129,12 +135,16 @@ void DomoticzMqttUpdate(void)
if (domoticz_update_timer <= 0) {
domoticz_update_timer = Settings.domoticz_update_timer;
for (uint32_t i = 1; i <= devices_present; i++) {
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan() && (i > 1)) {
MqttPublishDomoticzFanState();
break;
} else {
#endif // USE_SONOFF_IFAN
MqttPublishDomoticzPowerState(i);
#ifdef USE_SONOFF_IFAN
}
#endif // USE_SONOFF_IFAN
}
}
}
@ -214,6 +224,7 @@ bool DomoticzMqttData(void)
if (idx == Settings.domoticz_relay_idx[i]) {
bool iscolordimmer = strcmp_P(domoticz["dtype"],PSTR("Color Switch")) == 0;
snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), i +1);
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan() && (1 == i)) { // Idx 2 is fanspeed
uint8_t svalue = 0;
if (domoticz.containsKey("svalue1")) {
@ -231,8 +242,9 @@ bool DomoticzMqttData(void)
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_FANSPEED));
snprintf_P(XdrvMailbox.data, XdrvMailbox.data_len, PSTR("%d"), svalue);
found = 1;
}
else if (iscolordimmer && 10 == nvalue) { // Color_SetColor
} else
#endif // USE_SONOFF_IFAN
if (iscolordimmer && 10 == nvalue) { // Color_SetColor
JsonObject& color = domoticz["Color"];
uint16_t level = nvalue = domoticz["svalue1"];
uint16_t r = color["r"]; r = r * level / 100;
@ -472,7 +484,9 @@ void HandleDomoticzConfiguration(void)
WSContentSend_P(HTTP_FORM_DOMOTICZ_SWITCH,
i +1, i, Settings.domoticz_switch_idx[i]);
}
#ifdef USE_SONOFF_IFAN
if (IsModuleIfan() && (1 == i)) { break; }
#endif // USE_SONOFF_IFAN
}
for (uint32_t i = 0; i < DZ_MAX_SENSORS; i++) {
WSContentSend_P(HTTP_FORM_DOMOTICZ_SENSOR,

View File

@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef USE_SONOFF_IFAN
/*********************************************************************************************\
Sonoff iFan02 and iFan03
\*********************************************************************************************/
@ -32,6 +33,7 @@ const uint8_t kIFan03Sequence[MAX_FAN_SPEED][MAX_FAN_SPEED] = {{0, 2, 2, 2}, {0,
uint8_t ifan_fanspeed_timer = 0;
uint8_t ifan_fanspeed_goal = 0;
bool ifan_receive_flag = false;
bool ifan_restart_flag = true;
/*********************************************************************************************/
@ -236,6 +238,12 @@ void SonoffIfanUpdate(void)
}
}
}
if (ifan_restart_flag && (4 == uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands
ifan_restart_flag = false;
SetDevicePower(1, SRC_RETRY); // Sync with default power on state microcontroller being Light ON and Fan OFF
SetDevicePower(power, SRC_RETRY); // Set required power on state
}
}
/*********************************************************************************************\
@ -264,3 +272,5 @@ bool Xdrv22(uint8_t function)
}
return result;
}
#endif // USE_SONOFF_IFAN