From e74d9b0417d6199e42acbff58dcf5791a72721bf Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 23 Sep 2022 11:21:38 +0200 Subject: [PATCH] Fronius: Fix generating childs with multiple fronius connections --- fronius/froniussolarconnection.cpp | 6 ++++-- fronius/integrationpluginfronius.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fronius/froniussolarconnection.cpp b/fronius/froniussolarconnection.cpp index 49d98d92..d34bfe4d 100644 --- a/fronius/froniussolarconnection.cpp +++ b/fronius/froniussolarconnection.cpp @@ -188,11 +188,13 @@ void FroniusSolarConnection::sendNextRequest() m_currentReply = m_requestQueue.dequeue(); - qCDebug(dcFronius()) << "Connection: Sending request" << m_currentReply->request().url().toString(); +// qCDebug(dcFronius()) << "Connection: Sending request" << m_currentReply->request().url().toString(); m_currentReply->setNetworkReply(m_networkManager->get(m_currentReply->request())); connect(m_currentReply, &FroniusNetworkReply::finished, this, [=](){ - qCDebug(dcFronius()) << "Connection: Request finished" << m_currentReply->networkReply()->error(); + if (m_currentReply->networkReply()->error() != QNetworkReply::NoError) { + qCWarning(dcFronius()) << "Connection: Request finished with error:" << m_currentReply->networkReply()->error() << "for url" << m_currentReply->request().url().toString(); + } // Note: the network reply will be deleted in the destructor m_currentReply->deleteLater(); diff --git a/fronius/integrationpluginfronius.cpp b/fronius/integrationpluginfronius.cpp index 9d51c166..036f145f 100644 --- a/fronius/integrationpluginfronius.cpp +++ b/fronius/integrationpluginfronius.cpp @@ -283,7 +283,7 @@ void IntegrationPluginFronius::refreshConnection(FroniusSolarConnection *connect const QString serialNumber = inverterInfo.value("Serial").toString(); // Note: we use the id to identify for backwards compatibility - if (myThings().filterByParam(inverterThingIdParamTypeId, inverterId).isEmpty()) { + if (myThings().filterByParentId(connectionThing->id()).filterByParam(inverterThingIdParamTypeId, inverterId).isEmpty()) { QString thingDescription = connectionThing->name(); ThingDescriptor descriptor(inverterThingClassId, "Fronius Solar Inverter", thingDescription, connectionThing->id()); ParamList params; @@ -298,7 +298,7 @@ void IntegrationPluginFronius::refreshConnection(FroniusSolarConnection *connect QVariantMap meterMap = bodyMap.value("Data").toMap().value("Meter").toMap(); foreach (const QString &meterId, meterMap.keys()) { // Note: we use the id to identify for backwards compatibility - if (myThings().filterByParam(meterThingIdParamTypeId, meterId).isEmpty()) { + if (myThings().filterByParentId(connectionThing->id()).filterByParam(meterThingIdParamTypeId, meterId).isEmpty()) { // Get the meter realtime data for details FroniusNetworkReply *realtimeDataReply = connection->getMeterRealtimeData(meterId.toInt()); connect(realtimeDataReply, &FroniusNetworkReply::finished, this, [=]() { @@ -342,7 +342,7 @@ void IntegrationPluginFronius::refreshConnection(FroniusSolarConnection *connect QVariantMap storageMap = bodyMap.value("Data").toMap().value("Storage").toMap(); foreach (const QString &storageId, storageMap.keys()) { // Note: we use the id to identify for backwards compatibility - if (myThings().filterByParam(storageThingIdParamTypeId, storageId).isEmpty()) { + if (myThings().filterByParentId(connectionThing->id()).filterByParam(storageThingIdParamTypeId, storageId).isEmpty()) { // Get the meter realtime data for details FroniusNetworkReply *realtimeDataReply = connection->getStorageRealtimeData(storageId.toInt());