diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index 99ce209ad..fb30655ed 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -58,7 +58,6 @@ private: byte prevPreset = 0; byte prevPlaylist = 0; - bool savedState = false; uint32_t offTimerStart = 0; // off timer start time byte NotifyUpdateMode = CALL_MODE_NO_NOTIFY; // notification mode for colorUpdated(): CALL_MODE_NO_NOTIFY or CALL_MODE_DIRECT_CHANGE @@ -77,6 +76,7 @@ private: bool m_mqttOnly = false; // flag to send MQTT message only (assuming it is enabled) // flag to enable triggering only if WLED is initially off (LEDs are not on, preventing running effect being overwritten by PIR) bool m_offOnly = false; + bool m_offMode = offMode; // strings to reduce flash memory usage (used more than twice) static const char _name[]; @@ -123,13 +123,15 @@ private: PIRtriggered = switchOn; if (switchOn) { if (m_onPreset) { - if (currentPlaylist>0) prevPlaylist = currentPlaylist; - else if (currentPreset>0) prevPreset = currentPreset; - else { + if (currentPlaylist>0 && !offMode) { + prevPlaylist = currentPlaylist; + unloadPlaylist(); + } else if (currentPreset>0 && !offMode) { + prevPreset = currentPreset; + } else { saveTemporaryPreset(); - savedState = true; prevPlaylist = 0; - prevPreset = 0; + prevPreset = 255; } applyPreset(m_onPreset, NotifyUpdateMode); return; @@ -148,13 +150,10 @@ private: prevPlaylist = 0; return; } else if (prevPreset) { - applyPreset(prevPreset, NotifyUpdateMode); + if (prevPreset<255) applyPreset(prevPreset, NotifyUpdateMode); + else applyTemporaryPreset(); prevPreset = 0; return; - } else if (savedState) { - applyTemporaryPreset(); - savedState = false; - return; } // preset not assigned if (bri != 0) { diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 4e7a78140..4feb25a93 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -63,6 +63,7 @@ void handlePresets() if (!errorFlag && presetToApply < 255) currentPreset = presetToApply; + effectChanged = true; //force UDP notification colorUpdated(callModeToApply); updateInterfaces(callModeToApply); diff --git a/wled00/wled.h b/wled00/wled.h index ee6e391f9..ef09b17cc 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2201081 +#define VERSION 2201091 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG