From 48c267c5c1cd72bf51e27cf32b091d9cb1e06ced Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 5 Feb 2023 17:57:22 +0100 Subject: [PATCH] Bugfix. --- usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index 2b274d27..83c84711 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -114,6 +114,7 @@ private: if (m_offOnly && bri && (switchOn || (!PIRtriggered && !switchOn))) return; //if lights on and off only, do nothing if (PIRtriggered && switchOn) return; //if already on and triggered before, do nothing PIRtriggered = switchOn; + DEBUG_PRINT(F("PIR: strip=")); DEBUG_PRINTLN(switchOn?"on":"off"); if (switchOn) { if (m_onPreset) { if (currentPlaylist>0 && !offMode) { @@ -374,8 +375,10 @@ public: * onStateChanged() is used to detect WLED state change */ void onStateChange(uint8_t mode) { - if (PIRtriggered) { - DEBUG_PRINTLN(F("PIR canceled.")); + DEBUG_PRINT(F("PIR: offTimerStart=")); DEBUG_PRINTLN(offTimerStart); + if (PIRtriggered && offTimerStart) { + // checking PIRtriggered and offTimerStart will prevent cancellation upon On trigger + DEBUG_PRINTLN(F("PIR: Canceled.")); offTimerStart = 0; PIRtriggered = false; }