WS notifications on PIR state change.

This commit is contained in:
Blaz Kristan 2021-12-27 15:40:29 +01:00
parent eac5340b03
commit 7d6f8eb495

View File

@ -188,10 +188,12 @@ private:
if (sensorPinState == HIGH) { if (sensorPinState == HIGH) {
offTimerStart = 0; offTimerStart = 0;
if (!m_mqttOnly && (!m_nightTimeOnly || (m_nightTimeOnly && !isDayTime()))) switchStrip(true); if (!m_mqttOnly && (!m_nightTimeOnly || (m_nightTimeOnly && !isDayTime()))) switchStrip(true);
else if (NotifyUpdateMode != CALL_MODE_NO_NOTIFY) updateInterfaces(CALL_MODE_WS_SEND);
publishMqtt("on"); publishMqtt("on");
} else /*if (bri != 0)*/ { } else {
// start switch off timer // start switch off timer
offTimerStart = millis(); offTimerStart = millis();
if (NotifyUpdateMode != CALL_MODE_NO_NOTIFY) updateInterfaces(CALL_MODE_WS_SEND);
} }
return true; return true;
} }
@ -203,14 +205,13 @@ private:
*/ */
bool handleOffTimer() bool handleOffTimer()
{ {
if (offTimerStart > 0 && millis() - offTimerStart > m_switchOffDelay) if (offTimerStart > 0 && millis() - offTimerStart > m_switchOffDelay) {
{ offTimerStart = 0;
if (enabled == true) if (enabled == true) {
{
if (!m_mqttOnly && (!m_nightTimeOnly || (m_nightTimeOnly && !isDayTime()))) switchStrip(false); if (!m_mqttOnly && (!m_nightTimeOnly || (m_nightTimeOnly && !isDayTime()))) switchStrip(false);
else if (NotifyUpdateMode != CALL_MODE_NO_NOTIFY) updateInterfaces(CALL_MODE_WS_SEND);
publishMqtt("off"); publishMqtt("off");
} }
offTimerStart = 0;
return true; return true;
} }
return false; return false;