From b25ad6e35b5da2f02efe11a36f49cff27f771a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 18 Mar 2021 11:33:39 +0100 Subject: [PATCH] Fix lambda and start timer after setup finished --- sma/integrationpluginsma.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sma/integrationpluginsma.cpp b/sma/integrationpluginsma.cpp index 1e07df4e..6a8b2cff 100644 --- a/sma/integrationpluginsma.cpp +++ b/sma/integrationpluginsma.cpp @@ -93,20 +93,21 @@ void IntegrationPluginSma::setupThing(ThingSetupInfo *info) connect(info, &ThingSetupInfo::aborted, sunnyWebBox, &SunnyWebBox::deleteLater); connect(sunnyWebBox, &SunnyWebBox::destroyed, this, [thing, this] { m_sunnyWebBoxes.remove(thing);}); QString requestId = sunnyWebBox->getPlantOverview(); - connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, info, [sunnyWebBox, info, this] { - qCDebug(dcSma()) << "Received plant overview, finishing setup"; + connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, info, [=] (const QString &messageId, SunnyWebBox::Overview overview) { + qCDebug(dcSma()) << "Received plant overview" << messageId << "Finish setup"; + Q_UNUSED(overview) + info->finish(Thing::ThingErrorNoError); connect(sunnyWebBox, &SunnyWebBox::connectedChanged, this, &IntegrationPluginSma::onConnectedChanged); connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, this, &IntegrationPluginSma::onPlantOverviewReceived); m_sunnyWebBoxes.insert(info->thing(), sunnyWebBox); + + if (!m_refreshTimer) { + qCDebug(dcSma()) << "Starting refresh timer"; + m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(1); + connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginSma::onRefreshTimer); + } }); - - if (!m_refreshTimer) { - qCDebug(dcSma()) << "Starting refresh timer"; - m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(1); - connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginSma::onRefreshTimer); - } - } else { Q_ASSERT_X(false, "setupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); }