Update mqtt connected state to thing after setup

master
Simon Stürz 2022-07-21 16:38:51 +02:00
parent d13e90d722
commit 1a7ee36e2d
1 changed files with 16 additions and 0 deletions

View File

@ -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;
}
}
}
}