Perform init when the connection is reachable instead of connected.

pull/75/head
Simon Stürz 2022-08-08 14:57:28 +02:00
parent ee65c18400
commit d11a9eb38d
1 changed files with 3 additions and 3 deletions

View File

@ -119,9 +119,9 @@ void IntegrationPluginPhoenixConnect::setupThing(ThingSetupInfo *info)
}
});
connect(connection, &PhoenixModbusTcpConnection::connectionStateChanged, thing, [connection, thing](bool status){
qCDebug(dcPhoenixContact()) << "Connection state changed" << status;
if (status) {
connect(connection, &PhoenixModbusTcpConnection::reachableChanged, thing, [connection, thing](bool reachable){
qCDebug(dcPhoenixContact()) << "Reachable state changed" << reachable;
if (reachable) {
connection->initialize();
} else {
thing->setStateValue("connected", false);