diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index df7de51ec..c2d3463dc 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1389,14 +1389,14 @@ void GpioInit(void) } #endif // USE_I2C - devices_present = 1; - + devices_present = 0; light_type = LT_BASIC; // Use basic PWM control if SetOption15 = 0 if (XdrvCall(FUNC_MODULE_INIT)) { // Serviced } else if (YTF_IR_BRIDGE == my_module_type) { ClaimSerial(); // Stop serial loopback mode +// devices_present = 1; } else if (SONOFF_DUAL == my_module_type) { Settings.flag.mqtt_serial = 0; @@ -1415,7 +1415,6 @@ void GpioInit(void) } if (!light_type) { - devices_present = 0; for (uint32_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only if (pin[GPIO_PWM1 +i] < 99) { pwm_present = true; diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index bc2adb690..b041b0ac2 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1068,6 +1068,10 @@ bool LightModuleInit(void) light_type = LT_PWM2; } + if (light_type > LT_BASIC) { + devices_present++; + } + // post-process for lights if (Settings.flag3.pwm_multi_channels) { uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7); @@ -1075,7 +1079,7 @@ bool LightModuleInit(void) devices_present += pwm_channels - 1; // add the pwm channels controls at the end } - return (light_type > 0); + return (light_type > LT_BASIC); } void LightInit(void) diff --git a/sonoff/xdrv_16_tuyamcu.ino b/sonoff/xdrv_16_tuyamcu.ino index db190f58f..5a8402ba7 100644 --- a/sonoff/xdrv_16_tuyamcu.ino +++ b/sonoff/xdrv_16_tuyamcu.ino @@ -469,8 +469,6 @@ bool TuyaModuleSelected(void) bool relaySet = false; - devices_present--; - for (uint8_t i = 0 ; i < MAX_TUYA_FUNCTIONS; i++) { if ((Settings.tuya_fnid_map[i].fnid >= TUYA_MCU_FUNC_REL1 && Settings.tuya_fnid_map[i].fnid <= TUYA_MCU_FUNC_REL8 ) || (Settings.tuya_fnid_map[i].fnid >= TUYA_MCU_FUNC_REL1_INV && Settings.tuya_fnid_map[i].fnid <= TUYA_MCU_FUNC_REL8_INV )) { @@ -486,6 +484,7 @@ bool TuyaModuleSelected(void) } if (TuyaGetDpId(TUYA_MCU_FUNC_DIMMER) != 0) { + devices_present++; light_type = LT_SERIAL1; } else { light_type = LT_BASIC; diff --git a/sonoff/xdrv_18_armtronix_dimmers.ino b/sonoff/xdrv_18_armtronix_dimmers.ino index 2e6542b36..88860c853 100644 --- a/sonoff/xdrv_18_armtronix_dimmers.ino +++ b/sonoff/xdrv_18_armtronix_dimmers.ino @@ -86,6 +86,7 @@ void ArmtronixRequestState(void) bool ArmtronixModuleSelected(void) { + devices_present++; light_type = LT_SERIAL2; return true; } diff --git a/sonoff/xdrv_19_ps16dz_dimmer.ino b/sonoff/xdrv_19_ps16dz_dimmer.ino index 0c637a2ae..01e837dc6 100644 --- a/sonoff/xdrv_19_ps16dz_dimmer.ino +++ b/sonoff/xdrv_19_ps16dz_dimmer.ino @@ -125,10 +125,11 @@ bool PS16DZModuleSelected(void) switch (my_module_type) { case PS_16_DZ: + devices_present++; light_type = LT_SERIAL1; break; - case SONOFF_L1: + devices_present++; light_type = LT_PWM3; break; }