WakeOnLan: Update to new network device discovery
parent
a35312b7f2
commit
9ffd4321e6
|
|
@ -55,15 +55,16 @@ void IntegrationPluginWakeOnLan::discoverThings(ThingDiscoveryInfo *info)
|
||||||
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
||||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, discoveryReply, &NetworkDeviceDiscoveryReply::deleteLater);
|
||||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||||
ThingDescriptors descriptors;
|
|
||||||
qCDebug(dcWakeOnLan()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
qCDebug(dcWakeOnLan()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||||
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||||
// We need the mac address...
|
|
||||||
if (networkDeviceInfo.macAddress().isEmpty())
|
// We need a unique mac
|
||||||
|
if (networkDeviceInfo.monitorMode() != NetworkDeviceInfo::MonitorModeMac)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
MacAddressInfo macInfo = networkDeviceInfo.macAddressInfos().constFirst();
|
||||||
// Filter out already added network devices, rediscovery is in this case no option
|
// Filter out already added network devices, rediscovery is in this case no option
|
||||||
if (myThings().filterByParam(wolThingMacParamTypeId, networkDeviceInfo.macAddress()).count() != 0)
|
if (myThings().filterByParam(wolThingMacParamTypeId, macInfo.macAddress().toString()).count() != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
|
|
@ -73,25 +74,22 @@ void IntegrationPluginWakeOnLan::discoverThings(ThingDiscoveryInfo *info)
|
||||||
title = networkDeviceInfo.hostName() + " (" + networkDeviceInfo.address().toString() + ")";
|
title = networkDeviceInfo.hostName() + " (" + networkDeviceInfo.address().toString() + ")";
|
||||||
}
|
}
|
||||||
QString description;
|
QString description;
|
||||||
if (networkDeviceInfo.macAddressManufacturer().isEmpty()) {
|
if (macInfo.vendorName().isEmpty()) {
|
||||||
description = networkDeviceInfo.macAddress();
|
description = macInfo.macAddress().toString();
|
||||||
} else {
|
} else {
|
||||||
description = networkDeviceInfo.macAddress() + " (" + networkDeviceInfo.macAddressManufacturer() + ")";
|
description = macInfo.macAddress().toString() + " (" + macInfo.vendorName() + ")";
|
||||||
}
|
}
|
||||||
ThingDescriptor descriptor(wolThingClassId, title, description);
|
ThingDescriptor descriptor(wolThingClassId, title, description);
|
||||||
ParamList params;
|
descriptor.setParams({Param(wolThingMacParamTypeId, macInfo.macAddress().toString())});
|
||||||
params.append(Param(wolThingMacParamTypeId, networkDeviceInfo.macAddress()));
|
info->addThingDescriptor(descriptor);
|
||||||
descriptor.setParams(params);
|
|
||||||
descriptors.append(descriptor);
|
|
||||||
}
|
}
|
||||||
info->addThingDescriptors(descriptors);
|
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginWakeOnLan::executeAction(ThingActionInfo *info)
|
void IntegrationPluginWakeOnLan::executeAction(ThingActionInfo *info)
|
||||||
{
|
{
|
||||||
qCDebug(dcWakeOnLan) << "Wake up" << info->thing()->name();
|
qCInfo(dcWakeOnLan) << "Wake up" << info->thing()->name();
|
||||||
wakeup(info->thing()->paramValue(wolThingMacParamTypeId).toString());
|
wakeup(info->thing()->paramValue(wolThingMacParamTypeId).toString());
|
||||||
return info->finish(Thing::ThingErrorNoError);
|
return info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
"name": "mac",
|
"name": "mac",
|
||||||
"displayName": "MAC address",
|
"displayName": "MAC address",
|
||||||
"type": "QString",
|
"type": "QString",
|
||||||
"inputType": "MacAddress"
|
"inputType": "MacAddress",
|
||||||
|
"defaultValue": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actionTypes": [
|
"actionTypes": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue