Merge PR #688: Bosswerk: Don't poll the device when it's unreachable

master
jenkins 2023-05-16 12:59:15 +02:00
commit a670785b79
1 changed files with 5 additions and 2 deletions

View File

@ -158,10 +158,11 @@ void IntegrationPluginBosswerk::setupThing(ThingSetupInfo *info)
timer = hardwareManager()->pluginTimerManager()->registerTimer(5);
m_timers.insert(thing, timer);
connect(monitor, &NetworkDeviceMonitor::reachableChanged, thing, [timer, thing](bool reachable) {
connect(monitor, &NetworkDeviceMonitor::reachableChanged, thing, [this, timer, thing](bool reachable) {
thing->setStateValue(mix00ConnectedStateTypeId, reachable);
if (reachable) {
timer->start();
pollDevice(thing);
} else {
timer->stop();
thing->setStateValue(mix00CurrentPowerStateTypeId, 0);
@ -169,7 +170,9 @@ void IntegrationPluginBosswerk::setupThing(ThingSetupInfo *info)
});
connect(timer, &PluginTimer::timeout, thing, [this, thing](){
if (m_deviceMonitors.value(thing)->reachable()) {
pollDevice(thing);
}
});
pollDevice(thing);