From c3f1f41e6483133300aba733cdfd5162e2d8b106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 29 Nov 2021 16:53:43 +0100 Subject: [PATCH] Try to make a workaround for broken API version loggers --- fronius/integrationpluginfronius.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fronius/integrationpluginfronius.cpp b/fronius/integrationpluginfronius.cpp index e194c4d1..bfcfae62 100644 --- a/fronius/integrationpluginfronius.cpp +++ b/fronius/integrationpluginfronius.cpp @@ -151,8 +151,9 @@ void IntegrationPluginFronius::setupThing(ThingSetupInfo *info) // Knwon version with broken JSON API if (versionResponseMap.value("CompatibilityRange").toString() == "1.6-2") { qCWarning(dcFronius()) << "The Fronius data logger has a version which is known to have a broken JSON API firmware."; - info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("The firmware version 1.6-2 of this Fronius data logger has a broken API. Please update your Fronius device.")); - return; + // FIXME: temporary disable the version check in order to try to make it work nether the less + // info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("The firmware version 1.6-2 of this Fronius data logger has a broken API. Please update your Fronius device.")); + // return; } FroniusLogger *newLogger = new FroniusLogger(thing, this); @@ -420,6 +421,18 @@ void IntegrationPluginFronius::searchNewThings(FroniusLogger *logger) } } + // Note: in case of well known broken API version 1.6-2 the inverter map is broken and contains "1": { ... + if (bodyMap.value("Data").toMap().contains("1")) { + if (!thingExists(inverterThingIdParamTypeId, "1")) { + QString thingName = loggerThing->name() + " Inverter " + "1"; + ThingDescriptor descriptor(inverterThingClassId, thingName, "Fronius Solar Inverter", loggerThing->id()); + ParamList params; + params.append(Param(inverterThingIdParamTypeId, 1)); + descriptor.setParams(params); + thingDescriptors.append(descriptor); + } + } + // parse reply for meter things at the host address QVariantMap meterMap = bodyMap.value("Data").toMap().value("Meter").toMap(); foreach (const QString &meterId, meterMap.keys()) {