From cd79bb517f5653ca89f1fa6d71ae3ada59e32a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 4 Nov 2021 13:18:01 +0100 Subject: [PATCH] Fix max charging current if keba retuns 0 for hardware limit --- keba/integrationpluginkeba.cpp | 10 +++++++--- keba/integrationpluginkeba.json | 35 ++++++++++++++++----------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/keba/integrationpluginkeba.cpp b/keba/integrationpluginkeba.cpp index 64fdebae..370e9728 100644 --- a/keba/integrationpluginkeba.cpp +++ b/keba/integrationpluginkeba.cpp @@ -157,7 +157,7 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info) thing->setStateValue(wallboxFirmwareStateTypeId, report.firmware); thing->setStateValue(wallboxSerialnumberStateTypeId, report.serialNumber); thing->setStateValue(wallboxModelStateTypeId, report.product); - thing->setStateValue(wallboxUptimeStateTypeId, report.seconds/60); + thing->setStateValue(wallboxUptimeStateTypeId, report.seconds / 60); m_kebaDevices.insert(thing->id(), keba); info->finish(Thing::ThingErrorNoError); @@ -435,8 +435,12 @@ void IntegrationPluginKeba::onReportTwoReceived(const KeContact::ReportTwo &repo thing->setStateValue(wallboxMaxChargingCurrentPercentStateTypeId, reportTwo.maxCurrentPercentage); // Set the state limits according to the hardware limits - thing->setStateMaxValue(wallboxMaxChargingCurrentStateTypeId, reportTwo.currentHardwareLimitation); - + if (reportTwo.currentHardwareLimitation > 0) { + thing->setStateMaxValue(wallboxMaxChargingCurrentStateTypeId, reportTwo.currentHardwareLimitation); + } else { + // If we have no limit given, reset to the statetype limit + thing->setStateMaxValue(wallboxMaxChargingCurrentStateTypeId, thing->thingClass().getStateType(wallboxMaxChargingCurrentStateTypeId).maxValue()); + } thing->setStateValue(wallboxOutputX2StateTypeId, reportTwo.output); thing->setStateValue(wallboxInputStateTypeId, reportTwo.input); diff --git a/keba/integrationpluginkeba.json b/keba/integrationpluginkeba.json index 1b6f86e0..0b35bff6 100644 --- a/keba/integrationpluginkeba.json +++ b/keba/integrationpluginkeba.json @@ -43,22 +43,6 @@ "defaultValue": false, "cached": false }, - { - "id": "b44bc948-1234-4f87-9a22-bfb6de09df4d", - "name": "error1", - "displayName": "Error 1", - "displayNameEvent": "Error 1 changed", - "type": "int", - "defaultValue": 0 - }, - { - "id": "afca201a-5213-43fe-bfec-cae6ce7509d2", - "name": "error2", - "displayName": "Error 2", - "displayNameEvent": "Error 2 changed", - "type": "int", - "defaultValue": 0 - }, { "id": "c3fca233-95b9-4948-88c6-4c0f13cf53b1", "name": "model", @@ -167,8 +151,7 @@ "unit": "Percentage", "defaultValue": 100, "minValue": 0, - "maxValue": 100, - "suggestLogging": true + "maxValue": 100 }, { "id": "4a2d75d8-a3a0-4b40-9ca7-e8b6f11d0ef9", @@ -310,6 +293,22 @@ "unit": "Minutes", "defaultValue": 0 }, + { + "id": "b44bc948-1234-4f87-9a22-bfb6de09df4d", + "name": "error1", + "displayName": "Error 1", + "displayNameEvent": "Error 1 changed", + "type": "int", + "defaultValue": 0 + }, + { + "id": "afca201a-5213-43fe-bfec-cae6ce7509d2", + "name": "error2", + "displayName": "Error 2", + "displayNameEvent": "Error 2 changed", + "type": "int", + "defaultValue": 0 + }, { "id": "f1758c5c-2c02-41cb-93ec-b778a3c78d28", "name": "failsafeMode",