Improve it a bit more

pull/256/head
Michael Zanetti 2020-04-14 11:40:16 +02:00
parent 37081a51bd
commit 5768ebca91
1 changed files with 11 additions and 9 deletions

View File

@ -57,18 +57,20 @@ void IntegrationPluginOneWire::discoverThings(ThingDiscoveryInfo *info)
foreach(Thing *parentDevice, myThings().filterByThingClassId(oneWireInterfaceThingClassId)) {
if (parentDevice->stateValue(oneWireInterfaceAutoAddStateTypeId).toBool()) {
//devices cannot be discovered since auto mode is enabled
return info->finish(Thing::ThingErrorNoError);
} else {
m_runningDiscoveries.insert(parentDevice, info);
connect(info, &ThingDiscoveryInfo::destroyed, this, [this, parentDevice](){
m_runningDiscoveries.remove(parentDevice);
});
if (m_oneWireInterface)
m_oneWireInterface->discoverDevices();
continue;
}
m_runningDiscoveries.insert(parentDevice, info);
connect(info, &ThingDiscoveryInfo::destroyed, this, [this, parentDevice](){
m_runningDiscoveries.remove(parentDevice);
});
if (m_oneWireInterface)
m_oneWireInterface->discoverDevices();
}
if (m_runningDiscoveries.isEmpty()) {
info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("All configured one wire interfaces are set up to automatically add new devices."));
}
return;
}