Fix hue motion sensor timeout settings

master
Michael Zanetti 2020-04-01 15:24:29 +02:00
parent ac6dcf0765
commit 3c3f1b26cf
3 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -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 &paramTypeId, 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 &paramTypeId, const QVariant &value){
if (paramTypeId == outdoorSensorSettingsTimeoutParamTypeId) {
outdoorSensor->setTimeout(value.toUInt() * 1000);
outdoorSensor->setTimeout(value.toUInt());
}
});

View File

@ -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",