From 641df673624286ac6fb02a8e8af66c63cf41f9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 21 Mar 2021 12:00:00 +0100 Subject: [PATCH] only perform interlock delay once Before the delay was executed for *each* device being turned off. Therefore the delay grew with the size of the interlock group. --- tasmota/support_tasmota.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 9ad44d32e..94d18f9dc 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -556,18 +556,22 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source) ((POWER_ON == state) || ((POWER_TOGGLE == state) && !(TasmotaGlobal.power & mask))) ) { interlock_mutex = true; // Clear all but masked relay in interlock group if new set requested + bool perform_interlock_delay = false; for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) { if (Settings.interlock[i] & mask) { // Find interlock group for (uint32_t j = 0; j < TasmotaGlobal.devices_present; j++) { power_t imask = 1 << j; if ((Settings.interlock[i] & imask) && (TasmotaGlobal.power & imask) && (mask != imask)) { ExecuteCommandPower(j +1, POWER_OFF, SRC_IGNORE); - delay(50); // Add some delay to make sure never have more than one relay on + perform_interlock_delay = true; } } break; // An interlocked relay is only present in one group so quit } } + if (perform_interlock_delay) { + delay(50); // Add some delay to make sure never have more than one relay on + } interlock_mutex = false; }