From 49b7e2a57e29ac8e15756384e5cbe4af10ffc16f Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 16 Jan 2023 12:24:36 +0100 Subject: [PATCH] Mennekes: Discard unknown discovery results --- mennekes/amtronecudiscovery.cpp | 5 +++++ mennekes/amtronhcc3discovery.cpp | 6 ++++++ mennekes/integrationpluginmennekes.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/mennekes/amtronecudiscovery.cpp b/mennekes/amtronecudiscovery.cpp index 27c3eaa..fde1c85 100644 --- a/mennekes/amtronecudiscovery.cpp +++ b/mennekes/amtronecudiscovery.cpp @@ -83,6 +83,11 @@ void AmtronECUDiscovery::checkNetworkDevice(const NetworkDeviceInfo &networkDevi cleanupConnection(connection); return; } + if (connection->firmwareVersion() == 0 || connection->model().isEmpty()) { + qCDebug(dcMennekes()) << "Firmware version or model invalid. Skipping" << networkDeviceInfo.address(); + cleanupConnection(connection); + return; + } Result result; result.firmwareVersion = connection->firmwareVersion(); result.model = connection->model(); diff --git a/mennekes/amtronhcc3discovery.cpp b/mennekes/amtronhcc3discovery.cpp index 873e1e9..bd5c7d8 100644 --- a/mennekes/amtronhcc3discovery.cpp +++ b/mennekes/amtronhcc3discovery.cpp @@ -85,6 +85,12 @@ void AmtronHCC3Discovery::checkNetworkDevice(const NetworkDeviceInfo &networkDev cleanupConnection(connection); return; } + if (connection->serialNumber() == 0 || connection->name().isEmpty()) { + qCDebug(dcMennekes()) << "Serial number or name invalid. Skipping" << networkDeviceInfo.address(); + cleanupConnection(connection); + return; + } + AmtronDiscoveryResult result; result.wallboxName = connection->name(); result.serialNumber = connection->serialNumber(); diff --git a/mennekes/integrationpluginmennekes.cpp b/mennekes/integrationpluginmennekes.cpp index 1569841..264e828 100644 --- a/mennekes/integrationpluginmennekes.cpp +++ b/mennekes/integrationpluginmennekes.cpp @@ -61,6 +61,9 @@ void IntegrationPluginMennekes::discoverThings(ThingDiscoveryInfo *info) name = "AMTRON Charge Control"; } else if (result.model.startsWith("P")) { name = "AMTRON Professional"; + } else { + qCWarning(dcMennekes()) << "Unknown Amtron model:" << result.model; + continue; } ThingDescriptor descriptor(amtronECUThingClassId, name, description); qCDebug(dcMennekes()) << "Discovered:" << descriptor.title() << descriptor.description(); @@ -98,6 +101,7 @@ void IntegrationPluginMennekes::discoverThings(ThingDiscoveryInfo *info) descriptor.setThingId(existingThings.first()->id()); } + ParamList params; params << Param(amtronHCC3ThingMacAddressParamTypeId, result.networkDeviceInfo.macAddress()); // Note: if we discover also the port and modbusaddress, we must fill them in from the discovery here, for now everywhere the defaults...