From 3c3f1b26cf7bd2131524866fb7b707a754daad0b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 1 Apr 2020 15:24:29 +0200 Subject: [PATCH] Fix hue motion sensor timeout settings --- philipshue/huemotionsensor.cpp | 2 +- philipshue/integrationpluginphilipshue.cpp | 8 ++++---- philipshue/integrationpluginphilipshue.json | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/philipshue/huemotionsensor.cpp b/philipshue/huemotionsensor.cpp index 86671312..292113cb 100644 --- a/philipshue/huemotionsensor.cpp +++ b/philipshue/huemotionsensor.cpp @@ -49,7 +49,7 @@ 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((timeout - 9)* 1000); + m_timeout.setInterval(qMax(timeout - 9, 1)* 1000); } int HueMotionSensor::temperatureSensorId() const diff --git a/philipshue/integrationpluginphilipshue.cpp b/philipshue/integrationpluginphilipshue.cpp index fd4185bc..402bc0e1 100644 --- a/philipshue/integrationpluginphilipshue.cpp +++ b/philipshue/integrationpluginphilipshue.cpp @@ -421,7 +421,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info) qCDebug(dcPhilipsHue) << "Setup Hue motion sensor" << thing->params(); HueIndoorSensor *motionSensor = new HueIndoorSensor(this); - motionSensor->setTimeout(thing->setting(motionSensorSettingsTimeoutParamTypeId).toUInt() * 1000); + motionSensor->setTimeout(thing->setting(motionSensorSettingsTimeoutParamTypeId).toUInt()); motionSensor->setUuid(thing->paramValue(motionSensorThingUuidParamTypeId).toString()); motionSensor->setModelId(thing->paramValue(motionSensorThingModelIdParamTypeId).toString()); motionSensor->setTemperatureSensorId(thing->paramValue(motionSensorThingSensorIdTemperatureParamTypeId).toInt()); @@ -439,7 +439,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info) connect(thing, &Thing::settingChanged, motionSensor, [motionSensor](const ParamTypeId ¶mTypeId, const QVariant &value){ if (paramTypeId == motionSensorSettingsTimeoutParamTypeId) { - motionSensor->setTimeout(value.toUInt() * 1000); + motionSensor->setTimeout(value.toUInt()); } }); @@ -453,7 +453,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info) qCDebug(dcPhilipsHue) << "Setup Hue Outdoor sensor" << thing->params(); HueMotionSensor *outdoorSensor = new HueOutdoorSensor(this); - outdoorSensor->setTimeout(thing->setting(outdoorSensorSettingsTimeoutParamTypeId).toUInt() * 1000); + outdoorSensor->setTimeout(thing->setting(outdoorSensorSettingsTimeoutParamTypeId).toUInt()); outdoorSensor->setUuid(thing->paramValue(outdoorSensorThingUuidParamTypeId).toString()); outdoorSensor->setModelId(thing->paramValue(outdoorSensorThingModelIdParamTypeId).toString()); outdoorSensor->setTemperatureSensorId(thing->paramValue(outdoorSensorThingSensorIdTemperatureParamTypeId).toInt()); @@ -471,7 +471,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info) connect(thing, &Thing::settingChanged, outdoorSensor, [outdoorSensor](const ParamTypeId ¶mTypeId, const QVariant &value){ if (paramTypeId == outdoorSensorSettingsTimeoutParamTypeId) { - outdoorSensor->setTimeout(value.toUInt() * 1000); + outdoorSensor->setTimeout(value.toUInt()); } }); diff --git a/philipshue/integrationpluginphilipshue.json b/philipshue/integrationpluginphilipshue.json index d09e64a7..e31fa8d7 100644 --- a/philipshue/integrationpluginphilipshue.json +++ b/philipshue/integrationpluginphilipshue.json @@ -714,7 +714,8 @@ "displayName": "Person is present", "displayNameEvent": "Person is present changed", "type": "bool", - "defaultValue": false + "defaultValue": false, + "cached": false }, { "id": "6fa16fb2-053c-4c3c-a39b-9548c1b15089", @@ -856,7 +857,8 @@ "displayName": "Person is present", "displayNameEvent": "Person is present changed", "type": "bool", - "defaultValue": false + "defaultValue": false, + "cached": false }, { "id": "ef2e564e-2443-448f-bcd9-f85a1126ee6a",