update the sensor properly
This commit is contained in:
parent
81ae0888bd
commit
b42740de52
@ -135,13 +135,14 @@ void DevicePluginDaylightSensor::updateDevice(Device *device)
|
|||||||
} else if (now < sunset) {
|
} else if (now < sunset) {
|
||||||
timeToNext = now.secsTo(sunset);
|
timeToNext = now.secsTo(sunset);
|
||||||
} else {
|
} else {
|
||||||
timeToNext = now.secsTo(sunrise) + (60 * 60 * 24);
|
timeToNext = (60 * 60 * 24) - (now.time().msecsSinceStartOfDay() / 1000);
|
||||||
}
|
}
|
||||||
// Refresh at earliest in 5 secs to avoid spamming the system when we get close
|
// Refresh at earliest in 5 secs to avoid spamming the system when we get close
|
||||||
timeToNext = qMax(static_cast<int>(timeToNext), 5);
|
timeToNext = qMax(static_cast<int>(timeToNext), 1);
|
||||||
|
|
||||||
timer = hardwareManager()->pluginTimerManager()->registerTimer(static_cast<int>(timeToNext));
|
timer = hardwareManager()->pluginTimerManager()->registerTimer(static_cast<int>(timeToNext));
|
||||||
qCDebug(dcDaylightSensor()) << "Recalculating in" << timer->interval() << "seconds";
|
qCDebug(dcDaylightSensor()) << "Recalculating in" << timer->interval() << "seconds";
|
||||||
|
connect(timer, &PluginTimer::timeout, this, &DevicePluginDaylightSensor::pluginTimerEvent);
|
||||||
m_timers.insert(device, timer);
|
m_timers.insert(device, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user