From 179a3ea3acba39d61984230adc67622c8ddccbec Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 29 Oct 2020 23:01:16 +0100 Subject: [PATCH] Hue: Fix motionsensor flickering with low intervals --- philipshue/huemotionsensor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/philipshue/huemotionsensor.cpp b/philipshue/huemotionsensor.cpp index 292113cb..15d0c0fa 100644 --- a/philipshue/huemotionsensor.cpp +++ b/philipshue/huemotionsensor.cpp @@ -48,8 +48,12 @@ HueMotionSensor::HueMotionSensor(QObject *parent) : void HueMotionSensor::setTimeout(int timeout) { - // The sensor keeps emitting presence = true for 10 secs, let's subtract that time from the timeout to compensate - m_timeout.setInterval(qMax(timeout - 9, 1)* 1000); + // Once the sensor detects a motion it will keep emitting presence = true once a second for 10 secs. + // Let's subtract 9 seconds from the timeout to compensate for that but keep it greater than 2 secs + // to be sure to wait long enough even if the notification from the sensor takes little longer than + // 1 second due to network latency. + qCDebug(dcPhilipsHue()) << "Motion sensor timeout changed to:" << timeout; + m_timeout.setInterval(qMax(timeout - 9, 2)* 1000); } int HueMotionSensor::temperatureSensorId() const