From 1a7ee36e2d83bb610986a53b1bd95b8b8ed53269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 21 Jul 2022 16:38:51 +0200 Subject: [PATCH] Update mqtt connected state to thing after setup --- goecharger/integrationplugingoecharger.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/goecharger/integrationplugingoecharger.cpp b/goecharger/integrationplugingoecharger.cpp index b5dafda1..0cbe1aef 100644 --- a/goecharger/integrationplugingoecharger.cpp +++ b/goecharger/integrationplugingoecharger.cpp @@ -212,6 +212,22 @@ void IntegrationPluginGoECharger::postSetupThing(Thing *thing) connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginGoECharger::refreshHttp); m_refreshTimer->start(); } + + if (thing->paramValue(goeHomeThingUseMqttParamTypeId).toBool()) { + // make sure the connected state has been set properly + switch (getApiVersion(thing)) { + case ApiVersion1: + if (m_mqttChannelsV1.contains(thing)) { + thing->setStateValue("connected", m_mqttChannelsV1.value(thing)->isConnected()); + } + break; + case ApiVersion2: + if (m_mqttChannelsV2.contains(thing)) { + thing->setStateValue("connected", m_mqttChannelsV2.value(thing)->isConnected()); + } + break; + } + } } }