From 9a8377f93ab772d9aafb5ceae44896c599bcc371 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 20 Dec 2022 23:35:39 +0100 Subject: [PATCH 1/2] Mennekes: Reject wallboxes where the firmware is too old --- mennekes/integrationpluginmennekes.cpp | 10 ++++++++++ ...7c3c65c-a0cc-4ab1-90d8-4ad05bfcdc38-en_US.ts | 17 +++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/mennekes/integrationpluginmennekes.cpp b/mennekes/integrationpluginmennekes.cpp index 3e21175..832cc9d 100644 --- a/mennekes/integrationpluginmennekes.cpp +++ b/mennekes/integrationpluginmennekes.cpp @@ -389,6 +389,16 @@ void IntegrationPluginMennekes::setupAmtronECUConnection(ThingSetupInfo *info) } qCDebug(dcMennekes()) << "Connection init finished successfully" << amtronECUConnection; + + QString minimumVersion = "5.22"; + if (!ensureAmtronECUVersion(amtronECUConnection, minimumVersion)) { + qCWarning(dcMennekes()) << "Firmware version too old:" << QByteArray::fromHex(QByteArray::number(amtronECUConnection->firmwareVersion(), 16)) << "Minimum required:" << minimumVersion; + hardwareManager()->networkDeviceDiscovery()->unregisterMonitor(monitor); + amtronECUConnection->deleteLater(); + info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("The firmware version of this wallbox is too old. Please upgrade the firmware to at least version 5.22.")); + return; + } + m_amtronECUConnections.insert(thing, amtronECUConnection); info->finish(Thing::ThingErrorNoError); diff --git a/mennekes/translations/c7c3c65c-a0cc-4ab1-90d8-4ad05bfcdc38-en_US.ts b/mennekes/translations/c7c3c65c-a0cc-4ab1-90d8-4ad05bfcdc38-en_US.ts index 1ae03de..3179782 100644 --- a/mennekes/translations/c7c3c65c-a0cc-4ab1-90d8-4ad05bfcdc38-en_US.ts +++ b/mennekes/translations/c7c3c65c-a0cc-4ab1-90d8-4ad05bfcdc38-en_US.ts @@ -9,23 +9,28 @@ - - + + The MAC address is not known. Please reconfigure the thing. - - + + The host address is not known yet. Trying later again. - - + + Error communicating with the wallbox. + + + The firmware version of this wallbox is too old. Please upgrade the firmware to at least version 5.22. + + Mennekes From 4fb80af76ea6be4f7ad6cf54c7bb00e921c6d28e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 20 Dec 2022 23:38:38 +0100 Subject: [PATCH 2/2] Mennekes: Assume full range limits if vehicle or cable can't report the max --- mennekes/integrationpluginmennekes.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mennekes/integrationpluginmennekes.cpp b/mennekes/integrationpluginmennekes.cpp index 832cc9d..1569841 100644 --- a/mennekes/integrationpluginmennekes.cpp +++ b/mennekes/integrationpluginmennekes.cpp @@ -427,8 +427,13 @@ void IntegrationPluginMennekes::setupAmtronECUConnection(ThingSetupInfo *info) qCDebug(dcMennekes()) << "min current limit changed:" << minCurrentLimit; thing->setStateMinValue(amtronECUMaxChargingCurrentStateTypeId, minCurrentLimit); }); - connect(amtronECUConnection, &AmtronECUModbusTcpConnection::maxCurrentLimitChanged, thing, [thing](quint16 maxCurrentLimit) { + connect(amtronECUConnection, &AmtronECUModbusTcpConnection::maxCurrentLimitChanged, thing, [this, thing](quint16 maxCurrentLimit) { qCDebug(dcMennekes()) << "max current limit changed:" << maxCurrentLimit; + // If the vehicle or cable are not capable of reporting the maximum, this will be 0 + // We'll reset to the max defined in the json file in that case + if (maxCurrentLimit == 0) { + maxCurrentLimit = supportedThings().findById(amtronECUThingClassId).stateTypes().findById(amtronECUMaxChargingCurrentStateTypeId).maxValue().toUInt(); + } thing->setStateMaxValue(amtronECUMaxChargingCurrentStateTypeId, maxCurrentLimit); }); connect(amtronECUConnection, &AmtronECUModbusTcpConnection::hemsCurrentLimitChanged, thing, [thing](quint16 hemsCurrentLimit) {