From 63f6a14bc0a1aa7f7a1b9d0768dae9131e346134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 7 Oct 2018 21:21:36 +0200 Subject: [PATCH] Apply relay boot mask only on first 8 relays --- code/espurna/relay.ino | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 135be43f..df01fbc4 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -507,27 +507,34 @@ void _relayBoot() { DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask); // Walk the relays - bool status = false; + bool status; for (unsigned int i=0; i<_relays.size(); i++) { + unsigned char boot_mode = getSetting("relayBoot", i, RELAY_BOOT_MODE).toInt(); DEBUG_MSG_P(PSTR("[RELAY] Relay #%d boot mode %d\n"), i, boot_mode); + + status = false; switch (boot_mode) { case RELAY_BOOT_SAME: - status = ((mask & bit) == bit); + if (i < 8) { + status = ((mask & bit) == bit); + } break; case RELAY_BOOT_TOGGLE: - status = ((mask & bit) != bit); - mask ^= bit; - trigger_save = true; + if (i < 8) { + status = ((mask & bit) != bit); + mask ^= bit; + trigger_save = true; + } break; case RELAY_BOOT_ON: status = true; break; case RELAY_BOOT_OFF: default: - status = false; break; } + _relays[i].current_status = !status; _relays[i].target_status = status; #if RELAY_PROVIDER == RELAY_PROVIDER_STM