From 9c1cec487558d521d5ed1cce71250435babc4edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 25 Jun 2025 15:27:03 +0200 Subject: [PATCH] Add DC charging --- everest/integrationplugineverest.cpp | 14 ++- everest/integrationplugineverest.json | 134 +++++++++++++++++++++++ everest/jsonrpc/everestevse.cpp | 5 + everest/jsonrpc/everestevse.h | 2 + everest/jsonrpc/everestjsonrpcclient.cpp | 12 ++ everest/jsonrpc/everestjsonrpcclient.h | 3 + 6 files changed, 169 insertions(+), 1 deletion(-) diff --git a/everest/integrationplugineverest.cpp b/everest/integrationplugineverest.cpp index 5afe61e6..a88bd3cb 100644 --- a/everest/integrationplugineverest.cpp +++ b/everest/integrationplugineverest.cpp @@ -369,7 +369,6 @@ void IntegrationPluginEverest::setupThing(ThingSetupInfo *info) } } - // TODO: evaluate if any thing dissapeared if (!descriptors.isEmpty()) { @@ -394,6 +393,19 @@ void IntegrationPluginEverest::setupThing(ThingSetupInfo *info) info->finish(Thing::ThingErrorNoError); + connection->addThing(thing); + return; + } else if (thing->thingClassId() == everestChargerDcThingClassId) { + + Thing *parentThing = myThings().findById(thing->parentId()); + EverestConnection *connection = m_everstConnections.value(parentThing); + if (!connection) { + info->finish(Thing::ThingErrorHardwareNotAvailable); + return; + } + + info->finish(Thing::ThingErrorNoError); + connection->addThing(thing); return; } diff --git a/everest/integrationplugineverest.json b/everest/integrationplugineverest.json index f5b64779..5ff408c7 100644 --- a/everest/integrationplugineverest.json +++ b/everest/integrationplugineverest.json @@ -388,6 +388,140 @@ "eventTypes": [ ] + }, + { + "name": "everestChargerDc", + "displayName": "EVerest charger DC", + "id": "b31e14dd-43e0-4278-b517-d50afd6806ec", + "createMethods": ["auto"], + "interfaces": [ "evchargerdc", "connectable"], + "stateTypes": [ + { + "id": "e02d8186-a678-4e5a-aea7-460109617a02", + "name": "connected", + "displayName": "Connected", + "type": "bool", + "defaultValue": true + }, + { + "id": "c7b313bf-d12d-434f-b754-d0ada7209fe5", + "name": "power", + "displayName": "Charging enabled", + "displayNameAction": "Enable/disable charging", + "type": "bool", + "defaultValue": true, + "writable": true + }, + { + "id": "4dc2b506-990b-4e84-8a4b-444aba489ac2", + "name": "currentPower", + "displayName": "Measured power (AC side)", + "type": "double", + "unit": "Watt", + "defaultValue": 0 + }, + { + "id": "4c1415c2-bb2e-412a-9861-12ad8daa9051", + "name": "chargingPower", + "displayName": "Charging power", + "displayNameAction": "Set charging power", + "type": "double", + "unit": "Watt", + "defaultValue": 0, + "writable": true + }, + { + "id": "2e17f569-807e-4906-8748-0bd094cfd5d2", + "name": "chargingState", + "displayName": "Charging state", + "type": "QString", + "possibleValues": ["idle", "charging", "discharging"], + "defaultValue": "idle" + }, + { + "id": "2a78e62c-3b54-47bf-b4ff-b21f6eff9b04", + "name": "batteryLevel", + "displayName": "Battery level", + "type": "int", + "unit": "Percentage", + "minValue": 0, + "maxValue": 100, + "defaultValue": 50 + }, + { + "id": "ba4aa397-8d09-4e12-8eca-1d567b536bda", + "name": "batteryCritical", + "displayName": "Battery level critical", + "type": "bool", + "defaultValue": false + }, + { + "id": "7dedd1a2-6c99-4c85-8511-319f45b4fc56", + "name": "minChargingPower", + "displayName": "Minimal charging power", + "type": "double", + "unit": "Watt", + "defaultValue": 100 + }, + { + "id": "e1f1936e-e038-4820-bb7c-46404859ae42", + "name": "maxChargingPower", + "displayName": "Maximal charging power", + "type": "double", + "unit": "Watt", + "defaultValue": 50000 + }, + { + "id": "60ce60bd-0a6b-4f76-b51b-c6d342b2a277", + "name": "minDischargingPower", + "displayName": "Minimal discharging power", + "type": "double", + "unit": "Watt", + "defaultValue": -100 + }, + { + "id": "5bd483e4-aae6-4e53-b208-d7caa5b7fbc6", + "name": "maxDischargingPower", + "displayName": "Maximal discharging power", + "type": "double", + "unit": "Watt", + "defaultValue": -50000 + }, + { + "id": "020e30ce-e3db-41ad-8066-a819ac1d4bd5", + "name": "pluggedIn", + "displayName": "Car is plugged in", + "type": "bool", + "defaultValue": true, + "cached": false + }, + { + "id": "c13e3183-0e16-466d-8040-8c64706c6609", + "name": "chargingCapabilities", + "displayName": "Charging capabilities", + "type": "QString", + "possibleValues": ["charging", "discharging", "bidirectional"], + "defaultValue": "charging", + "cached": false + }, + { + "id": "9bfc98a0-92f7-4b46-b390-72d8da721778", + "name": "totalEnergyConsumed", + "displayName": "Total consumed energy", + "type": "double", + "unit": "KiloWattHour", + "defaultValue": 0 + }, + { + "id": "782e6a0c-62e5-4b36-947c-c66ee1fa1737", + "name": "totalEnergyProduced", + "displayName": "Total returned energy", + "type": "double", + "unit": "KiloWattHour", + "defaultValue": 0 + } + ], + "actionTypes": [ ] } ] } diff --git a/everest/jsonrpc/everestevse.cpp b/everest/jsonrpc/everestevse.cpp index 1689d2a6..7af0acbf 100644 --- a/everest/jsonrpc/everestevse.cpp +++ b/everest/jsonrpc/everestevse.cpp @@ -74,6 +74,11 @@ EverestJsonRpcReply *EverestEvse::setACChargingPhaseCount(int phaseCount) return m_client->evseSetACChargingPhaseCount(m_index, phaseCount); } +EverestJsonRpcReply *EverestEvse::setDCChargingPower(double chargingPower) +{ + return m_client->evseSetDCChargingPower(m_index, chargingPower); +} + void EverestEvse::initialize() { qCDebug(dcEverest()) << "Evse: Initializing data for" << m_thing->name(); diff --git a/everest/jsonrpc/everestevse.h b/everest/jsonrpc/everestevse.h index c556fc2c..3be6531b 100644 --- a/everest/jsonrpc/everestevse.h +++ b/everest/jsonrpc/everestevse.h @@ -47,6 +47,8 @@ public: EverestJsonRpcReply *setACChargingCurrent(double current); EverestJsonRpcReply *setACChargingPhaseCount(int phaseCount); + EverestJsonRpcReply *setDCChargingPower(double chargingPower); + private: EverestJsonRpcClient *m_client = nullptr; Thing *m_thing = nullptr; diff --git a/everest/jsonrpc/everestjsonrpcclient.cpp b/everest/jsonrpc/everestjsonrpcclient.cpp index 6c91eee6..e7fe8e49 100644 --- a/everest/jsonrpc/everestjsonrpcclient.cpp +++ b/everest/jsonrpc/everestjsonrpcclient.cpp @@ -245,6 +245,18 @@ EverestJsonRpcReply *EverestJsonRpcClient::evseSetACChargingPhaseCount(int evseI return reply; } +EverestJsonRpcReply *EverestJsonRpcClient::evseSetDCChargingPower(int evseIndex, double chargingPower) +{ + QVariantMap params; + params.insert("evse_index", evseIndex); + params.insert("max_power", chargingPower); + + EverestJsonRpcReply *reply = new EverestJsonRpcReply(m_commandId, "EVSE.SetDCChargingPower", params, this); + qCDebug(dcEverest()) << "Calling" << reply->method() << params; + sendRequest(reply); + return reply; +} + EverestJsonRpcClient::ResponseError EverestJsonRpcClient::parseResponseError(const QString &responseErrorString) { QMetaEnum metaEnum = QMetaEnum::fromType(); diff --git a/everest/jsonrpc/everestjsonrpcclient.h b/everest/jsonrpc/everestjsonrpcclient.h index 194fe63c..0d8ca656 100644 --- a/everest/jsonrpc/everestjsonrpcclient.h +++ b/everest/jsonrpc/everestjsonrpcclient.h @@ -185,6 +185,9 @@ public: EverestJsonRpcReply *evseSetACChargingCurrent(int evseIndex, double current); EverestJsonRpcReply *evseSetACChargingPhaseCount(int evseIndex, int phaseCount); + EverestJsonRpcReply *evseSetDCChargingPower(int evseIndex, double chargingPower); + + // API parser methods // Enums