From f7fde95e7679e282d67971a84dbeeedac32db8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 22 Oct 2021 12:34:53 +0200 Subject: [PATCH] Add phase count state according to updated evcharger interface --- keba/integrationpluginkeba.cpp | 20 ++++++++++++++++++++ keba/integrationpluginkeba.json | 11 ++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/keba/integrationpluginkeba.cpp b/keba/integrationpluginkeba.cpp index b1e492ae..978d9332 100644 --- a/keba/integrationpluginkeba.cpp +++ b/keba/integrationpluginkeba.cpp @@ -458,6 +458,26 @@ void IntegrationPluginKeba::onReportThreeReceived(const KeContact::ReportThree & qCDebug(dcKeba()) << " - Serial number" << reportThree.serialNumber; qCDebug(dcKeba()) << " - Uptime" << reportThree.seconds/60 << "[min]"; + // Check how many phases are connected + if (reportThree.voltagePhase1 == 0 && reportThree.voltagePhase2 == 0 && reportThree.voltagePhase3 == 0) { + // Note: if not charging, all voltage values are 0, only set the phase count if any voltage gets reported. + } else { + uint phaseCount = 0; + if (reportThree.voltagePhase1 > 0) { + phaseCount += 1; + } + + if (reportThree.voltagePhase2 > 0) { + phaseCount += 1; + } + + if (reportThree.voltagePhase3 > 0) { + phaseCount += 1; + } + + thing->setStateValue(wallboxPhaseCountStateTypeId, phaseCount); + } + if (reportThree.serialNumber == thing->stateValue(wallboxSerialnumberStateTypeId).toString()) { thing->setStateValue(wallboxCurrentPhaseAEventTypeId, reportThree.currentPhase1); thing->setStateValue(wallboxCurrentPhaseBEventTypeId, reportThree.currentPhase2); diff --git a/keba/integrationpluginkeba.json b/keba/integrationpluginkeba.json index 08058dbb..987ad649 100644 --- a/keba/integrationpluginkeba.json +++ b/keba/integrationpluginkeba.json @@ -83,7 +83,6 @@ "type": "QString", "defaultValue": "" }, - { "id": "83ed0774-2a91-434d-b03c-d920d02f2981", "name": "power", @@ -103,6 +102,16 @@ "type": "bool", "defaultValue": false }, + { + "id": "6713b2e7-41b3-4596-a304-3065726bdbe4", + "name": "phaseCount", + "displayName": "Number of connected phases", + "displayNameEvent": "Number of connected phases changed", + "type": "uint", + "minValue": 1, + "maxValue": 3, + "defaultValue": 1 + }, { "id": "539e5602-6dd9-465d-9705-3bb59bcf8982", "name": "activity",