Improve it a bit more

This commit is contained in:
Michael Zanetti 2020-04-14 11:40:16 +02:00
parent 37081a51bd
commit 5768ebca91

View File

@ -57,8 +57,8 @@ void IntegrationPluginOneWire::discoverThings(ThingDiscoveryInfo *info)
foreach(Thing *parentDevice, myThings().filterByThingClassId(oneWireInterfaceThingClassId)) { foreach(Thing *parentDevice, myThings().filterByThingClassId(oneWireInterfaceThingClassId)) {
if (parentDevice->stateValue(oneWireInterfaceAutoAddStateTypeId).toBool()) { if (parentDevice->stateValue(oneWireInterfaceAutoAddStateTypeId).toBool()) {
//devices cannot be discovered since auto mode is enabled //devices cannot be discovered since auto mode is enabled
return info->finish(Thing::ThingErrorNoError); continue;
} else { }
m_runningDiscoveries.insert(parentDevice, info); m_runningDiscoveries.insert(parentDevice, info);
connect(info, &ThingDiscoveryInfo::destroyed, this, [this, parentDevice](){ connect(info, &ThingDiscoveryInfo::destroyed, this, [this, parentDevice](){
m_runningDiscoveries.remove(parentDevice); m_runningDiscoveries.remove(parentDevice);
@ -67,8 +67,10 @@ void IntegrationPluginOneWire::discoverThings(ThingDiscoveryInfo *info)
if (m_oneWireInterface) if (m_oneWireInterface)
m_oneWireInterface->discoverDevices(); 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; return;
} }