Update discovery to renamed network device
This commit is contained in:
parent
a61e6fd244
commit
3218e27971
@ -53,38 +53,38 @@ void IntegrationPluginKeba::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
||||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||||
ThingDescriptors descriptors;
|
ThingDescriptors descriptors;
|
||||||
qCDebug(dcKebaKeContact()) << "Discovery finished. Found" << discoveryReply->networkDevices().count() << "devices";
|
qCDebug(dcKebaKeContact()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||||
foreach (const NetworkDevice &networkDevice, discoveryReply->networkDevices()) {
|
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||||
if (!networkDevice.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
if (!networkDeviceInfo.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
qCDebug(dcKebaKeContact()) << " - Keba Wallbox" << networkDevice;
|
qCDebug(dcKebaKeContact()) << " - Keba Wallbox" << networkDeviceInfo;
|
||||||
QString title = "Wallbox ";
|
QString title = "Wallbox ";
|
||||||
if (networkDevice.hostName().isEmpty()) {
|
if (networkDeviceInfo.hostName().isEmpty()) {
|
||||||
title += networkDevice.address().toString();
|
title += networkDeviceInfo.address().toString();
|
||||||
} else {
|
} else {
|
||||||
title += networkDevice.hostName() + " (" + networkDevice.address().toString() + ")";
|
title += networkDeviceInfo.hostName() + " (" + networkDeviceInfo.address().toString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString description;
|
QString description;
|
||||||
if (networkDevice.macAddressManufacturer().isEmpty()) {
|
if (networkDeviceInfo.macAddressManufacturer().isEmpty()) {
|
||||||
description = networkDevice.macAddress();
|
description = networkDeviceInfo.macAddress();
|
||||||
} else {
|
} else {
|
||||||
description = networkDevice.macAddress() + " (" + networkDevice.macAddressManufacturer() + ")";
|
description = networkDeviceInfo.macAddress() + " (" + networkDeviceInfo.macAddressManufacturer() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingDescriptor descriptor(wallboxThingClassId, title, description);
|
ThingDescriptor descriptor(wallboxThingClassId, title, description);
|
||||||
|
|
||||||
// Check if we already have set up this device
|
// Check if we already have set up this device
|
||||||
Things existingThings = myThings().filterByParam(wallboxThingMacAddressParamTypeId, networkDevice.macAddress());
|
Things existingThings = myThings().filterByParam(wallboxThingMacAddressParamTypeId, networkDeviceInfo.macAddress());
|
||||||
if (existingThings.count() == 1) {
|
if (existingThings.count() == 1) {
|
||||||
qCDebug(dcKebaKeContact()) << "This wallbox already exists in the system!" << networkDevice;
|
qCDebug(dcKebaKeContact()) << "This wallbox already exists in the system!" << networkDeviceInfo;
|
||||||
descriptor.setThingId(existingThings.first()->id());
|
descriptor.setThingId(existingThings.first()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamList params;
|
ParamList params;
|
||||||
params << Param(wallboxThingMacAddressParamTypeId, networkDevice.macAddress());
|
params << Param(wallboxThingMacAddressParamTypeId, networkDeviceInfo.macAddress());
|
||||||
params << Param(wallboxThingIpAddressParamTypeId, networkDevice.address().toString());
|
params << Param(wallboxThingIpAddressParamTypeId, networkDeviceInfo.address().toString());
|
||||||
descriptor.setParams(params);
|
descriptor.setParams(params);
|
||||||
info->addThingDescriptor(descriptor);
|
info->addThingDescriptor(descriptor);
|
||||||
}
|
}
|
||||||
@ -275,30 +275,30 @@ void IntegrationPluginKeba::searchNetworkDevices()
|
|||||||
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
|
||||||
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){
|
||||||
ThingDescriptors descriptors;
|
ThingDescriptors descriptors;
|
||||||
qCDebug(dcKebaKeContact()) << "Discovery finished. Found" << discoveryReply->networkDevices().count() << "devices";
|
qCDebug(dcKebaKeContact()) << "Discovery finished. Found" << discoveryReply->networkDeviceInfos().count() << "devices";
|
||||||
foreach (const NetworkDevice &networkDevice, discoveryReply->networkDevices()) {
|
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
|
||||||
if (!networkDevice.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
if (!networkDeviceInfo.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (Thing *existingThing, myThings().filterByThingClassId(wallboxThingClassId)) {
|
foreach (Thing *existingThing, myThings().filterByThingClassId(wallboxThingClassId)) {
|
||||||
if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString().isEmpty()) {
|
if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString().isEmpty()) {
|
||||||
//This device got probably manually setup, to enable auto rediscovery the MAC address needs to setup
|
//This device got probably manually setup, to enable auto rediscovery the MAC address needs to setup
|
||||||
if (existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() == networkDevice.address().toString()) {
|
if (existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() == networkDeviceInfo.address().toString()) {
|
||||||
qCDebug(dcKebaKeContact()) << "Keba Wallbox MAC Address has been discovered" << existingThing->name() << networkDevice.macAddress();
|
qCDebug(dcKebaKeContact()) << "Keba Wallbox MAC Address has been discovered" << existingThing->name() << networkDeviceInfo.macAddress();
|
||||||
existingThing->setParamValue(wallboxThingMacAddressParamTypeId, networkDevice.macAddress());
|
existingThing->setParamValue(wallboxThingMacAddressParamTypeId, networkDeviceInfo.macAddress());
|
||||||
}
|
}
|
||||||
} else if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString() == networkDevice.macAddress()) {
|
} else if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString() == networkDeviceInfo.macAddress()) {
|
||||||
if (existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() != networkDevice.address().toString()) {
|
if (existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() != networkDeviceInfo.address().toString()) {
|
||||||
qCDebug(dcKebaKeContact()) << "Keba Wallbox IP Address has changed, from" << existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() << "to" << networkDevice.address().toString();
|
qCDebug(dcKebaKeContact()) << "Keba Wallbox IP Address has changed, from" << existingThing->paramValue(wallboxThingIpAddressParamTypeId).toString() << "to" << networkDeviceInfo.address().toString();
|
||||||
existingThing->setParamValue(wallboxThingIpAddressParamTypeId, networkDevice.address().toString());
|
existingThing->setParamValue(wallboxThingIpAddressParamTypeId, networkDeviceInfo.address().toString());
|
||||||
KeContact *keba = m_kebaDevices.value(existingThing->id());
|
KeContact *keba = m_kebaDevices.value(existingThing->id());
|
||||||
if (keba) {
|
if (keba) {
|
||||||
keba->setAddress(QHostAddress(networkDevice.address()));
|
keba->setAddress(QHostAddress(networkDeviceInfo.address()));
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcKebaKeContact()) << "Could not update IP address, for" << existingThing;
|
qCWarning(dcKebaKeContact()) << "Could not update IP address, for" << existingThing;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcKebaKeContact()) << "Keba Wallbox" << existingThing->name() << "IP address has not changed" << networkDevice.address().toString();
|
qCDebug(dcKebaKeContact()) << "Keba Wallbox" << existingThing->name() << "IP address has not changed" << networkDeviceInfo.address().toString();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user