From 1bf864c6ad5adb86e7b2e0acc4dc9e91e02ce076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 15 Dec 2021 11:04:42 +0100 Subject: [PATCH] Fix potential missing serialnumber in the thing params --- keba/integrationpluginkeba.cpp | 23 ++++++++++++++++++----- keba/kecontactdatalayer.cpp | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/keba/integrationpluginkeba.cpp b/keba/integrationpluginkeba.cpp index 65a20a9b..d484d02e 100644 --- a/keba/integrationpluginkeba.cpp +++ b/keba/integrationpluginkeba.cpp @@ -137,7 +137,8 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info) foreach (KeContact *kebaConnect, m_kebaDevices.values()) { if (kebaConnect->address() == address) { qCWarning(dcKeba()) << "Failed to set up keba for host address" << address.toString() << "because there has already been configured a keba for this IP."; - return info->finish(Thing::ThingErrorThingInUse, QT_TR_NOOP("Already configured for this IP address.")); + info->finish(Thing::ThingErrorThingInUse, QT_TR_NOOP("Already configured for this IP address.")); + return; } } @@ -158,6 +159,18 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info) qCDebug(dcKeba()) << " - Product" << report.product; qCDebug(dcKeba()) << " - Uptime" << report.seconds / 60 << "[min]"; qCDebug(dcKeba()) << " - Com Module" << report.comModule; + qCDebug(dcKeba()) << " - DIP switch 1" << report.dipSw1; + qCDebug(dcKeba()) << " - DIP switch 2" << report.dipSw2; + + if (thing->paramValue(wallboxThingSerialNumberParamTypeId).toString().isEmpty()) { + qCDebug(dcKeba()) << "Update serial number parameter for" << thing << "to" << report.serialNumber; + thing->setParamValue(wallboxThingSerialNumberParamTypeId, report.serialNumber); + } + + if (thing->paramValue(wallboxThingModelParamTypeId).toString().isEmpty()) { + qCDebug(dcKeba()) << "Update model parameter for" << thing << "to" << report.product; + thing->setParamValue(wallboxThingModelParamTypeId, report.product); + } // Verify the DIP switches and warn the user in case if wrong configuration // For having UPD controll on the wallbox we need DIP Switch 1.3 enabled @@ -169,12 +182,13 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info) return; } + m_kebaDevices.insert(thing->id(), keba); + info->finish(Thing::ThingErrorNoError); + qCDebug(dcKeba()) << "Setup finsihed successfully for" << thing << thing->params(); + thing->setStateValue(wallboxConnectedStateTypeId, true); thing->setStateValue(wallboxFirmwareStateTypeId, report.firmware); thing->setStateValue(wallboxUptimeStateTypeId, report.seconds / 60); - - m_kebaDevices.insert(thing->id(), keba); - info->finish(Thing::ThingErrorNoError); }); keba->getReport1(); @@ -363,7 +377,6 @@ void IntegrationPluginKeba::onCommandExecuted(QUuid requestId, bool success) } else if (info->action().actionTypeId() == wallboxPowerActionTypeId) { info->thing()->setStateValue(wallboxPowerStateTypeId, info->action().paramValue(wallboxPowerActionTypeId).toBool()); } - } else { qCWarning(dcKeba()) << "Action execution finished with error. Request ID:" << requestId.toString(); info->finish(Thing::ThingErrorHardwareFailure); diff --git a/keba/kecontactdatalayer.cpp b/keba/kecontactdatalayer.cpp index 8f9dd66b..806c1a60 100644 --- a/keba/kecontactdatalayer.cpp +++ b/keba/kecontactdatalayer.cpp @@ -88,7 +88,7 @@ void KeContactDataLayer::readPendingDatagrams() void KeContactDataLayer::onSocketError(QAbstractSocket::SocketError error) { - qCDebug(dcKeba()) << "KeContactDataLayer: Socket error" << error; + qCWarning(dcKeba()) << "KeContactDataLayer: Socket error" << error; } void KeContactDataLayer::onSocketStateChanged(QAbstractSocket::SocketState socketState)