From b35845cc997150d3fd9296d0dd6bcdfd8ee3c36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 28 Oct 2021 10:50:44 +0200 Subject: [PATCH 1/2] Update max charging current --- wallbe/integrationpluginwallbe.json | 2 +- webasto/integrationpluginwebasto.cpp | 4 ++-- webasto/integrationpluginwebasto.json | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wallbe/integrationpluginwallbe.json b/wallbe/integrationpluginwallbe.json index e968af2..aa7f37a 100644 --- a/wallbe/integrationpluginwallbe.json +++ b/wallbe/integrationpluginwallbe.json @@ -82,7 +82,7 @@ "displayName": "Charging current", "displayNameEvent": "Charging current changed", "displayNameAction": "Set charging current", - "type": "double", + "type": "uint", "unit": "Ampere", "minValue": 6, "maxValue": 80, diff --git a/webasto/integrationpluginwebasto.cpp b/webasto/integrationpluginwebasto.cpp index 7b37899..0994652 100644 --- a/webasto/integrationpluginwebasto.cpp +++ b/webasto/integrationpluginwebasto.cpp @@ -209,7 +209,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info) thing->setStateValue(liveWallboxPowerActionTypeId, enabled); int ampere = 0; if (enabled) { - ampere = thing->stateValue(liveWallboxMaxChargingCurrentStateTypeId).toInt(); + ampere = thing->stateValue(liveWallboxMaxChargingCurrentStateTypeId).toUInt(); } QUuid requestId = connection->setChargeCurrent(ampere); if (requestId.isNull()) { @@ -218,7 +218,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info) m_asyncActions.insert(requestId, info); } } else if (action.actionTypeId() == liveWallboxMaxChargingCurrentActionTypeId) { - int ampere = action.paramValue(liveWallboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt(); + int ampere = action.paramValue(liveWallboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); thing->setStateValue(liveWallboxMaxChargingCurrentStateTypeId, ampere); QUuid requestId = connection->setChargeCurrent(ampere); if (requestId.isNull()) { diff --git a/webasto/integrationpluginwebasto.json b/webasto/integrationpluginwebasto.json index c1717a2..2844375 100644 --- a/webasto/integrationpluginwebasto.json +++ b/webasto/integrationpluginwebasto.json @@ -91,11 +91,11 @@ "displayName": "Charging current", "displayNameAction": "Set charging current", "displayNameEvent": "Charging current changed", - "type": "double", + "type": "uint", "unit": "Ampere", - "minValue": 6.00, - "maxValue": 80.00, - "defaultValue": 6.00, + "minValue": 6, + "maxValue": 80, + "defaultValue": 6, "writable": true }, { From dfb30e8677753700efa559f709b0834731428186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 28 Oct 2021 12:51:48 +0200 Subject: [PATCH 2/2] Add webasto ev charger states --- webasto/integrationpluginwebasto.cpp | 30 +++++++++++++++++++++++++++ webasto/integrationpluginwebasto.h | 1 + webasto/integrationpluginwebasto.json | 26 +++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/webasto/integrationpluginwebasto.cpp b/webasto/integrationpluginwebasto.cpp index 0994652..dcf25be 100644 --- a/webasto/integrationpluginwebasto.cpp +++ b/webasto/integrationpluginwebasto.cpp @@ -266,6 +266,27 @@ void IntegrationPluginWebasto::update(Webasto *webasto) webasto->getRegister(Webasto::TqUserId, 10); } +void IntegrationPluginWebasto::evaluatePhaseCount(Thing *thing) +{ + uint amperePhase1 = thing->stateValue(liveWallboxCurrentPhase1StateTypeId).toUInt(); + uint amperePhase2 = thing->stateValue(liveWallboxCurrentPhase2StateTypeId).toUInt(); + uint amperePhase3 = thing->stateValue(liveWallboxCurrentPhase3StateTypeId).toUInt(); + // Check how many phases are actually charging, and update the phase count only if something happens on the phases (current or power) + if (!(amperePhase1 == 0 && amperePhase2 == 0 && amperePhase3 == 0)) { + uint phaseCount = 0; + if (amperePhase1 != 0) + phaseCount += 1; + + if (amperePhase2 != 0) + phaseCount += 1; + + if (amperePhase3 != 0) + phaseCount += 1; + + thing->setStateValue(liveWallboxPhaseCountStateTypeId, phaseCount); + } +} + void IntegrationPluginWebasto::onConnectionChanged(bool connected) { Webasto *connection = static_cast(sender()); @@ -339,6 +360,8 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb thing->setStateValue(liveWallboxChargePointStateStateTypeId, "User not authorized (car attached)"); break; } + + thing->setStateValue(liveWallboxChargingStateTypeId, Webasto::ChargePointState(data[0]) == Webasto::ChargePointStateCharging); break; case Webasto::TqChargeState: qCDebug(dcWebasto()) << " - Charge state:" << data[0]; @@ -351,15 +374,19 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb switch (Webasto::CableState(data[0])) { case Webasto::CableStateNoCableAttached: thing->setStateValue(liveWallboxCableStateStateTypeId, "No cable attached"); + thing->setStateValue(liveWallboxPluggedInStateTypeId, false); break; case Webasto::CableStateCableAttachedNoCarAttached: thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached but no car attached)"); + thing->setStateValue(liveWallboxPluggedInStateTypeId, false); break; case Webasto::CableStateCableAttachedCarAttached: thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached and car attached"); + thing->setStateValue(liveWallboxPluggedInStateTypeId, true); break; case Webasto::CableStateCableAttachedCarAttachedLockActive: thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached, car attached and lock active"); + thing->setStateValue(liveWallboxPluggedInStateTypeId, true); break; } break; @@ -370,14 +397,17 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb case Webasto::TqCurrentL1: qCDebug(dcWebasto()) << " - Current L1:" << data[0]; thing->setStateValue(liveWallboxCurrentPhase1StateTypeId, data[0]); + evaluatePhaseCount(thing); break; case Webasto::TqCurrentL2: qCDebug(dcWebasto()) << " - Current L2:" << data[0]; thing->setStateValue(liveWallboxCurrentPhase2StateTypeId, data[0]); + evaluatePhaseCount(thing); break; case Webasto::TqCurrentL3: qCDebug(dcWebasto()) << " - Current L3:" << data[0]; thing->setStateValue(liveWallboxCurrentPhase3StateTypeId, data[0]); + evaluatePhaseCount(thing); break; case Webasto::TqActivePower: { if (data.count() < 2) diff --git a/webasto/integrationpluginwebasto.h b/webasto/integrationpluginwebasto.h index 199cf1a..7822101 100644 --- a/webasto/integrationpluginwebasto.h +++ b/webasto/integrationpluginwebasto.h @@ -62,6 +62,7 @@ private: QHash m_asyncActions; void update(Webasto *webasto); + void evaluatePhaseCount(Thing *thing); private slots: void onConnectionChanged(bool connected); diff --git a/webasto/integrationpluginwebasto.json b/webasto/integrationpluginwebasto.json index 2844375..b329910 100644 --- a/webasto/integrationpluginwebasto.json +++ b/webasto/integrationpluginwebasto.json @@ -98,6 +98,32 @@ "defaultValue": 6, "writable": true }, + { + "id": "0e15e78e-a233-4026-a0fd-f65edc824f1e", + "name": "pluggedIn", + "displayName": "Car plugged in", + "displayNameEvent": "Car plugged in changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "8f35404d-8237-4ff8-8774-9ad10ceee5c3", + "name": "charging", + "displayName": "Charging", + "displayNameEvent": "Charging changed", + "type": "bool", + "defaultValue": false + }, + { + "id": "179e6136-2ac1-4247-b457-f804e2212293", + "name": "phaseCount", + "displayName": "Number of connected phases", + "displayNameEvent": "Number of connected phases changed", + "type": "uint", + "minValue": 1, + "maxValue": 3, + "defaultValue": 1 + }, { "id": "2027fbb6-c9d2-4a75-bdd0-a3ad3785cdc6", "name": "currentPhase1",