From ab8ef44cd1eb6772a294827840d59fdddf4c5514 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 2 Apr 2023 19:57:54 +0200 Subject: [PATCH] Bosswerk: Don't poll the device when it's unreachable --- bosswerk/integrationpluginbosswerk.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bosswerk/integrationpluginbosswerk.cpp b/bosswerk/integrationpluginbosswerk.cpp index 50127415..9856b9a1 100644 --- a/bosswerk/integrationpluginbosswerk.cpp +++ b/bosswerk/integrationpluginbosswerk.cpp @@ -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](){ - pollDevice(thing); + if (m_deviceMonitors.value(thing)->reachable()) { + pollDevice(thing); + } }); pollDevice(thing);