diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index 6b60bcb41..40a8a3050 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -45,22 +45,24 @@ const uint32_t POWER_SIZE = 32; // Power (relay) bit count * Constants \*********************************************************************************************/ +// Why 28? Because in addition to relays there may be lights and uint32_t bitmap can hold up to 32 devices #ifdef ESP8266 -const uint8_t MAX_RELAYS = 8; // Max number of relays (up to 28) +const uint8_t MAX_RELAYS = 8; // Max number of relays selectable on GPIO const uint8_t MAX_INTERLOCKS = 4; // Max number of interlock groups (up to MAX_INTERLOCKS_SET) -const uint8_t MAX_SWITCHES = 8; // Max number of switches (up to MAX_SWITCHES_SET) -const uint8_t MAX_KEYS = 8; // Max number of keys or buttons (up to 28) +const uint8_t MAX_SWITCHES = 8; // Max number of switches selectable on GPIO +const uint8_t MAX_KEYS = 8; // Max number of keys or buttons selectable on GPIO #endif // ESP8266 #ifdef ESP32 -const uint8_t MAX_RELAYS = 28; // Max number of relays (up to 28) +const uint8_t MAX_RELAYS = 28; // Max number of relays selectable on GPIO const uint8_t MAX_INTERLOCKS = 14; // Max number of interlock groups (up to MAX_INTERLOCKS_SET) -const uint8_t MAX_SWITCHES = 28; // Max number of switches (up to MAX_SWITCHES_SET) -const uint8_t MAX_KEYS = 28; // Max number of keys or buttons (up to 28) +const uint8_t MAX_SWITCHES = 28; // Max number of switches selectable on GPIO +const uint8_t MAX_KEYS = 28; // Max number of keys or buttons selectable on GPIO #endif // ESP32 +const uint8_t MAX_RELAYS_SET = 28; // Max number of relays const uint8_t MAX_KEYS_SET = 28; // Max number of keys // Changes to the following MAX_ defines will impact settings layout -const uint8_t MAX_INTERLOCKS_SET = 14; // Max number of interlock groups (MAX_RELAYS / 2) +const uint8_t MAX_INTERLOCKS_SET = 14; // Max number of interlock groups (MAX_RELAYS_SET / 2) const uint8_t MAX_SWITCHES_SET = 28; // Max number of switches const uint8_t MAX_LEDS = 4; // Max number of leds const uint8_t MAX_PWMS_LEGACY = 5; // Max number of PWM channels in first settings block - Legacy limit for ESP8266, but extended for ESP32 (see below) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_12_discovery.ino b/tasmota/tasmota_xdrv_driver/xdrv_12_discovery.ino index d0486f2a8..cd5bcb71b 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_12_discovery.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_12_discovery.ino @@ -88,7 +88,7 @@ void TasDiscoverMessage(void) { SettingsText(SET_MQTTPREFIX2), SettingsText(SET_MQTTPREFIX3)); - uint8_t light_idx = MAX_RELAYS + 1; // Will store the starting position of the lights + uint8_t light_idx = MAX_RELAYS_SET + 1; // Will store the starting position of the lights uint8_t light_subtype = 0; bool light_controller_isCTRGBLinked = false; #ifdef USE_LIGHT @@ -107,9 +107,9 @@ void TasDiscoverMessage(void) { } #endif // USE_LIGHT - uint16_t Relay[MAX_RELAYS] = { 0 }; // Base array to store the relay type - uint16_t Shutter[MAX_RELAYS] = { 0 }; // Array to store a temp list for shutters - for (uint32_t i = 0; i < MAX_RELAYS; i++) { + uint16_t Relay[MAX_RELAYS_SET] = { 0 }; // Base array to store the relay type + uint16_t Shutter[MAX_RELAYS_SET] = { 0 }; // Array to store a temp list for shutters + for (uint32_t i = 0; i < MAX_RELAYS_SET; i++) { if (i < TasmotaGlobal.devices_present) { #ifdef USE_SHUTTER diff --git a/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino b/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino index 5cc138881..2790bade4 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino @@ -282,7 +282,7 @@ void HassDiscoverMessage(void) { SettingsText(SET_MQTTPREFIX2), SettingsText(SET_MQTTPREFIX3)); - uint8_t light_idx = MAX_RELAYS + 1; // Will store the starting position of the lights + uint8_t light_idx = MAX_RELAYS_SET + 1; // Will store the starting position of the lights uint8_t light_subtype = 0; bool light_controller_isCTRGBLinked = false; #ifdef USE_LIGHT @@ -301,9 +301,9 @@ void HassDiscoverMessage(void) { } #endif // USE_LIGHT - uint16_t Relay[MAX_RELAYS] = { 0 }; // Base array to store the relay type - uint16_t Shutter[MAX_RELAYS] = { 0 }; // Array to store a temp list for shutters - for (uint32_t i = 0; i < MAX_RELAYS; i++) { + uint16_t Relay[MAX_RELAYS_SET] = { 0 }; // Base array to store the relay type + uint16_t Shutter[MAX_RELAYS_SET] = { 0 }; // Array to store a temp list for shutters + for (uint32_t i = 0; i < MAX_RELAYS_SET; i++) { if (i < TasmotaGlobal.devices_present) { #ifdef USE_SHUTTER