diff --git a/tasmota/tasmota_support/support_button_v4.ino b/tasmota/tasmota_support/support_button_v4.ino index 927b43ea3..af9bfc29a 100644 --- a/tasmota/tasmota_support/support_button_v4.ino +++ b/tasmota/tasmota_support/support_button_v4.ino @@ -500,6 +500,7 @@ void ButtonHandler(void) { XdrvMailbox.payload = Button.press_counter[button_index]; if (XdrvCall(FUNC_BUTTON_MULTI_PRESSED)) { // Serviced +// AddLog(LOG_LEVEL_DEBUG, PSTR("BTN: FUNC_BUTTON_MULTI_PRESSED serviced")); } else #ifdef ROTARY_V1 @@ -518,20 +519,9 @@ void ButtonHandler(void) { } else { SendKey(KEY_BUTTON, button_index +1, Button.press_counter[button_index] +9); // 2,3,4 and 5 press send just the key value (11,12,13 and 14) for rules if (0 == button_index) { // BUTTON1 can toggle up to 5 relays if present. If a relay is not present will send out the key value (2,11,12,13 and 14) for rules - bool valid_relay = PinUsed(GPIO_REL1, Button.press_counter[button_index]-1); -#ifdef ESP8266 - if ((SONOFF_DUAL == TasmotaGlobal.module_type) || (CH4 == TasmotaGlobal.module_type)) { - valid_relay = (Button.press_counter[button_index] <= TasmotaGlobal.devices_present); - } -#endif // ESP8266 -#ifdef USE_SHELLY_PRO - if (TasmotaGlobal.gpio_optiona.shelly_pro) { - valid_relay = (Button.press_counter[button_index] <= TasmotaGlobal.devices_present); - } -#endif // USE_SHELLY_PRO - if ((Button.press_counter[button_index] > 1) && valid_relay && (Button.press_counter[button_index] <= MAX_RELAY_BUTTON1)) { + uint32_t max_device = (TasmotaGlobal.devices_present < MAX_RELAY_BUTTON1) ? TasmotaGlobal.devices_present : MAX_RELAY_BUTTON1; + if ((Button.press_counter[button_index] > 1) && (Button.press_counter[button_index] <= max_device)) { ExecuteCommandPower(button_index + Button.press_counter[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally -// AddLog(LOG_LEVEL_DEBUG, PSTR("BTN: Relay%d found on GPIO%d"), Button.press_counter[button_index], Pin(GPIO_REL1, Button.press_counter[button_index]-1)); } } }