From e5f3dbedc48277a58679e33d45b7f9ef99711ff5 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 7 Mar 2023 14:34:48 +0100 Subject: [PATCH 1/4] Imporove discovery for Schrack --- schrack/ciondiscovery.cpp | 66 +++++++++++++++++++++++++++ schrack/ciondiscovery.h | 64 ++++++++++++++++++++++++++ schrack/integrationpluginschrack.cpp | 9 +--- schrack/integrationpluginschrack.json | 9 ---- schrack/schrack.pro | 2 + 5 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 schrack/ciondiscovery.cpp create mode 100644 schrack/ciondiscovery.h diff --git a/schrack/ciondiscovery.cpp b/schrack/ciondiscovery.cpp new file mode 100644 index 0000000..c2094f7 --- /dev/null +++ b/schrack/ciondiscovery.cpp @@ -0,0 +1,66 @@ +#include "ciondiscovery.h" + +#include"extern-plugininfo.h" + +CionDiscovery::CionDiscovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent) + : QObject{parent}, + m_modbusRtuResource{modbusRtuResource} +{ + +} + +void CionDiscovery::startDiscovery() +{ + qCInfo(dcSchrack()) << "Discovery: Searching for Schrack i-CHARGE wallboxes on modbus RTU..."; + + QList candidateMasters; + foreach (ModbusRtuMaster *master, m_modbusRtuResource->modbusRtuMasters()) { + if (master->baudrate() == 57600 && master->dataBits() == 8 && master->stopBits() == 1 && master->parity() == QSerialPort::NoParity) { + candidateMasters.append(master); + } + } + + if (candidateMasters.isEmpty()) { + qCWarning(dcSchrack()) << "No usable modbus RTU master found."; + emit discoveryFinished(false); + return; + } + + foreach (ModbusRtuMaster *master, candidateMasters) { + if (master->connected()) { + tryConnect(master, 1); + } else { + qCWarning(dcSchrack()) << "Modbus RTU master" << master->modbusUuid().toString() << "is not connected."; + } + } +} + +QList CionDiscovery::discoveryResults() const +{ + return m_discoveryResults; +} + +void CionDiscovery::tryConnect(ModbusRtuMaster *master, quint16 slaveId) +{ + qCDebug(dcSchrack()) << "Scanning modbus RTU master" << master->modbusUuid() << "Slave ID:" << slaveId; + + ModbusRtuReply *reply = master->readInputRegister(slaveId, 4); + connect(reply, &ModbusRtuReply::finished, this, [=](){ + qCDebug(dcSchrack()) << "Test reply finished!" << reply->error() << reply->result(); + if (reply->error() == ModbusRtuReply::NoError && reply->result().length() > 0) { + quint16 version = reply->result().first(); + if (version >= 0x0100) { + qCDebug(dcSchrack()) << QString("Version is 0x%1").arg(version, 0, 16); + Result result {master->modbusUuid(), version, slaveId}; + m_discoveryResults.append(result); + } else { + qCDebug(dcAmperfied()) << "Version must be at least 1.0.0 (0x0100)"; + } + } + if (slaveId < 20) { + tryConnect(master, slaveId+1); + } else { + emit discoveryFinished(true); + } + }); +} diff --git a/schrack/ciondiscovery.h b/schrack/ciondiscovery.h new file mode 100644 index 0000000..5e9f388 --- /dev/null +++ b/schrack/ciondiscovery.h @@ -0,0 +1,64 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2023, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea. +* This project including source code and documentation is protected by +* copyright law, and remains the property of nymea GmbH. All rights, including +* reproduction, publication, editing and translation, are reserved. The use of +* this project is subject to the terms of a license agreement to be concluded +* with nymea GmbH in accordance with the terms of use of nymea GmbH, available +* under https://nymea.io/license +* +* GNU Lesser General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the +* terms of the GNU Lesser General Public License as published by the Free +* Software Foundation; version 3. This project is distributed in the hope that +* it will be useful, but WITHOUT ANY WARRANTY; without even the implied +* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this project. If not, see . +* +* For any further details and any questions please contact us under +* contact@nymea.io or see our FAQ/Licensing Information on +* https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef CIONDISCOVERY_H +#define CIONDISCOVERY_H + +#include +#include + +class CionDiscovery : public QObject +{ + Q_OBJECT +public: + explicit CionDiscovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent = nullptr); + struct Result { + QUuid modbusRtuMasterId; + quint16 firmwareVersion; + quint16 slaveId; + }; + + void startDiscovery(); + + QList discoveryResults() const; + +signals: + void discoveryFinished(bool modbusRtuMasterAvailable); + +private slots: + void tryConnect(ModbusRtuMaster *master, quint16 slaveId); + +private: + ModbusRtuHardwareResource *m_modbusRtuResource = nullptr; + + QList m_discoveryResults; +}; + +#endif // CIONDISCOVERY_H diff --git a/schrack/integrationpluginschrack.cpp b/schrack/integrationpluginschrack.cpp index aa5877b..72b5169 100644 --- a/schrack/integrationpluginschrack.cpp +++ b/schrack/integrationpluginschrack.cpp @@ -48,16 +48,11 @@ void IntegrationPluginSchrack::discoverThings(ThingDiscoveryInfo *info) return; } - uint slaveAddress = info->params().paramValue(cionDiscoverySlaveAddressParamTypeId).toUInt(); - if (slaveAddress > 254 || slaveAddress == 0) { - info->finish(Thing::ThingErrorInvalidParameter, QT_TR_NOOP("The Modbus slave address must be a value between 1 and 254.")); - return; - } - foreach (ModbusRtuMaster *modbusMaster, hardwareManager()->modbusRtuResource()->modbusRtuMasters()) { qCDebug(dcSchrack()) << "Found RTU master resource" << modbusMaster << "connected" << modbusMaster->connected(); - if (!modbusMaster->connected()) + if (!modbusMaster->connected()) { continue; + } ThingDescriptor descriptor(info->thingClassId(), "i-CHARGE CION", QString::number(slaveAddress) + " " + modbusMaster->serialPort()); ParamList params; diff --git a/schrack/integrationpluginschrack.json b/schrack/integrationpluginschrack.json index 341a700..0c6c339 100644 --- a/schrack/integrationpluginschrack.json +++ b/schrack/integrationpluginschrack.json @@ -15,15 +15,6 @@ "id": "075d389d-3330-4d0b-9649-9f085120ca40", "createMethods": ["discovery"], "interfaces": ["evcharger", "connectable"], - "discoveryParamTypes": [ - { - "id": "8004705f-0e13-4713-b75e-49d115cd9517", - "name": "slaveAddress", - "displayName": "Slave address", - "type": "int", - "defaultValue": 1 - } - ], "paramTypes": [ { "id": "dac10e08-734c-4e71-a5d6-0d2a1f416ca6", diff --git a/schrack/schrack.pro b/schrack/schrack.pro index 94fae58..2b8023c 100644 --- a/schrack/schrack.pro +++ b/schrack/schrack.pro @@ -6,8 +6,10 @@ MODBUS_CONNECTIONS += cion-registers.json include(../modbus.pri) SOURCES += \ + ciondiscovery.cpp \ integrationpluginschrack.cpp HEADERS += \ + ciondiscovery.h \ integrationpluginschrack.h From 26a2aeab51dbe566dbdff269058ae7578d5edd6e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 7 Mar 2023 15:29:38 +0100 Subject: [PATCH 2/4] Schrack: Improve discovery --- schrack/README.md | 12 ++++++++ schrack/ciondiscovery.cpp | 30 ++++++++++++------- schrack/ciondiscovery.h | 2 +- schrack/integrationpluginschrack.cpp | 45 +++++++++++++++++----------- 4 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 schrack/README.md diff --git a/schrack/README.md b/schrack/README.md new file mode 100644 index 0000000..751d42a --- /dev/null +++ b/schrack/README.md @@ -0,0 +1,12 @@ +# Schrack CION + +This plugin adds support for the Schrack CION wallbox to nymea. + +The wallbox needs to be connected to the nymea system using an RS485 interface which needs to be configured as a Modbus RTU interface with the following parameters: +* Baudrate: 57600 +* Data bits: 8 +* Stop bit: 1 +* Parity: None + +Once the Modbus RTU interface is configured, the Wallbox can be added to nymea. nymea will try to discover the wallbox on the first 10 slave ids. This means, the DIP switches on the Wallbox are required to be configred for a modbus Slave ID from 1 to 10. + diff --git a/schrack/ciondiscovery.cpp b/schrack/ciondiscovery.cpp index c2094f7..63e1619 100644 --- a/schrack/ciondiscovery.cpp +++ b/schrack/ciondiscovery.cpp @@ -2,6 +2,9 @@ #include"extern-plugininfo.h" +#include + + CionDiscovery::CionDiscovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent) : QObject{parent}, m_modbusRtuResource{modbusRtuResource} @@ -44,20 +47,27 @@ void CionDiscovery::tryConnect(ModbusRtuMaster *master, quint16 slaveId) { qCDebug(dcSchrack()) << "Scanning modbus RTU master" << master->modbusUuid() << "Slave ID:" << slaveId; - ModbusRtuReply *reply = master->readInputRegister(slaveId, 4); + ModbusRtuReply *reply = master->readHoldingRegister(slaveId, 832, 16); connect(reply, &ModbusRtuReply::finished, this, [=](){ - qCDebug(dcSchrack()) << "Test reply finished!" << reply->error() << reply->result(); - if (reply->error() == ModbusRtuReply::NoError && reply->result().length() > 0) { - quint16 version = reply->result().first(); - if (version >= 0x0100) { - qCDebug(dcSchrack()) << QString("Version is 0x%1").arg(version, 0, 16); - Result result {master->modbusUuid(), version, slaveId}; + + if (reply->error() == ModbusRtuReply::NoError) { + + QString firmwareVersion = ModbusDataUtils::convertToString(reply->result()); + qCDebug(dcSchrack()) << "Test reply finished!" << reply->error() << firmwareVersion; + + // Version numbers seem to be wild west... We can't really understand what's in there... + // So let's assume this is a schrack if reading alone succeeded and it is a valid string and 18 to 32 chars long... + // Examples of how this looks like: + // EBE 1.2: "V1.2 15.02.2021" + // ICC: "003090056-01 20220913" + QRegExp re = QRegExp("[A-Z0-9\\.- ]{18,32}"); + if (re.exactMatch(firmwareVersion)) { + Result result {master->modbusUuid(), firmwareVersion, slaveId}; m_discoveryResults.append(result); - } else { - qCDebug(dcAmperfied()) << "Version must be at least 1.0.0 (0x0100)"; } } - if (slaveId < 20) { + + if (slaveId < 10) { tryConnect(master, slaveId+1); } else { emit discoveryFinished(true); diff --git a/schrack/ciondiscovery.h b/schrack/ciondiscovery.h index 5e9f388..6b3f80a 100644 --- a/schrack/ciondiscovery.h +++ b/schrack/ciondiscovery.h @@ -41,7 +41,7 @@ public: explicit CionDiscovery(ModbusRtuHardwareResource *modbusRtuResource, QObject *parent = nullptr); struct Result { QUuid modbusRtuMasterId; - quint16 firmwareVersion; + QString firmwareVersion; quint16 slaveId; }; diff --git a/schrack/integrationpluginschrack.cpp b/schrack/integrationpluginschrack.cpp index 72b5169..94d5cdb 100644 --- a/schrack/integrationpluginschrack.cpp +++ b/schrack/integrationpluginschrack.cpp @@ -31,6 +31,8 @@ #include "integrationpluginschrack.h" #include "plugininfo.h" +#include "ciondiscovery.h" + IntegrationPluginSchrack::IntegrationPluginSchrack() { } @@ -42,27 +44,36 @@ void IntegrationPluginSchrack::init() void IntegrationPluginSchrack::discoverThings(ThingDiscoveryInfo *info) { - qCDebug(dcSchrack()) << "Discovering modbus RTU resources..."; - if (hardwareManager()->modbusRtuResource()->modbusRtuMasters().isEmpty()) { - info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("No Modbus RTU interface available. Please set up a Modbus RTU interface first.")); - return; - } + CionDiscovery *discovery = new CionDiscovery(hardwareManager()->modbusRtuResource(), info); - foreach (ModbusRtuMaster *modbusMaster, hardwareManager()->modbusRtuResource()->modbusRtuMasters()) { - qCDebug(dcSchrack()) << "Found RTU master resource" << modbusMaster << "connected" << modbusMaster->connected(); - if (!modbusMaster->connected()) { - continue; + connect(discovery, &CionDiscovery::discoveryFinished, info, [this, info, discovery](bool modbusMasterAvailable){ + if (!modbusMasterAvailable) { + info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("No modbus RTU master with appropriate settings found. Please set up a modbus RTU master with a baudrate of 57600, 8 data bis, 1 stop bit and no parity first.")); + return; } - ThingDescriptor descriptor(info->thingClassId(), "i-CHARGE CION", QString::number(slaveAddress) + " " + modbusMaster->serialPort()); - ParamList params; - params << Param(cionThingSlaveAddressParamTypeId, slaveAddress); - params << Param(cionThingModbusMasterUuidParamTypeId, modbusMaster->modbusUuid()); - descriptor.setParams(params); - info->addThingDescriptor(descriptor); - } + qCInfo(dcSchrack()) << "Discovery results:" << discovery->discoveryResults().count(); - info->finish(Thing::ThingErrorNoError); + foreach (const CionDiscovery::Result &result, discovery->discoveryResults()) { + ThingDescriptor descriptor(cionThingClassId, "Schrack CION", QString("Slave ID: %1, Version: %2").arg(result.slaveId).arg(result.firmwareVersion)); + + ParamList params{ + {cionThingModbusMasterUuidParamTypeId, result.modbusRtuMasterId}, + {cionThingSlaveAddressParamTypeId, result.slaveId} + }; + descriptor.setParams(params); + + Thing *existingThing = myThings().findByParams(params); + if (existingThing) { + descriptor.setThingId(existingThing->id()); + } + info->addThingDescriptor(descriptor); + } + + info->finish(Thing::ThingErrorNoError); + }); + + discovery->startDiscovery(); } void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info) From 0ef0a8daf7a18cd67465e19fac68dde54b8fc01f Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 7 Mar 2023 15:43:15 +0100 Subject: [PATCH 3/4] Update translations --- schrack/integrationpluginschrack.json | 2 +- ...600beeb5-5c34-49fc-b2af-8f83c1b11eab-de.ts | 109 ++++++++++++++ ...beeb5-5c34-49fc-b2af-8f83c1b11eab-en_US.ts | 134 ++++-------------- 3 files changed, 137 insertions(+), 108 deletions(-) create mode 100644 schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-de.ts diff --git a/schrack/integrationpluginschrack.json b/schrack/integrationpluginschrack.json index 0c6c339..7210a3d 100644 --- a/schrack/integrationpluginschrack.json +++ b/schrack/integrationpluginschrack.json @@ -13,7 +13,7 @@ "name": "cion", "displayName": "i-CHARGE CION", "id": "075d389d-3330-4d0b-9649-9f085120ca40", - "createMethods": ["discovery"], + "createMethods": ["discovery", "user"], "interfaces": ["evcharger", "connectable"], "paramTypes": [ { diff --git a/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-de.ts b/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-de.ts new file mode 100644 index 0000000..df66743 --- /dev/null +++ b/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-de.ts @@ -0,0 +1,109 @@ + + + + + IntegrationPluginSchrack + + + No modbus RTU master with appropriate settings found. Please set up a modbus RTU master with a baudrate of 57600, 8 data bis, 1 stop bit and no parity first. + Es wurde mein Modbus RTU Master mit passenden Einstellungen gefunden. Bitte richte einen Modbus RTU Master mit einer Baudrate von 57600, 8 Daten-Bits, 1 Stop-Bit und keiner Parität ein. + + + + The Modbus address not valid. It must be a value between 1 and 254. + Die Modbus Addresse ist ungültig. Sie muss zwischen 1 und 254 sein. + + + + The Modbus RTU resource is not available. + Die Modbus RTU Ressource ist nicht verfügbar. + + + + schrack + + + Charging + The name of the StateType ({b59b4b4d-2cdb-4534-bf86-90123ae9bb1a}) of ThingClass cion + Ladend + + + + + Charging enabled + The name of the ParamType (ThingClass: cion, ActionType: power, ID: {61aea53a-bf8d-4fe6-859a-f1687e15d190}) +---------- +The name of the StateType ({61aea53a-bf8d-4fe6-859a-f1687e15d190}) of ThingClass cion + Laden freigegeben + + + + Connected + The name of the StateType ({b7aa8e49-a6c0-4b48-b65e-47259686185f}) of ThingClass cion + Verbunden + + + + Enable or disable charging + The name of the ActionType ({61aea53a-bf8d-4fe6-859a-f1687e15d190}) of ThingClass cion + Ladefreigabe erteilen/entfernen + + + + Firmware version + The name of the StateType ({33780b19-4855-4b5c-bd84-cec8400309be}) of ThingClass cion + Firmware-Version + + + + + Maximum charging current + The name of the ParamType (ThingClass: cion, ActionType: maxChargingCurrent, ID: {221af869-a796-46c2-a5e0-27c8972a0bf2}) +---------- +The name of the StateType ({221af869-a796-46c2-a5e0-27c8972a0bf2}) of ThingClass cion + Maximaler Ladestrom + + + + Modbus RTU master + The name of the ParamType (ThingClass: cion, Type: thing, ID: {636241a9-4838-48ae-bcc8-3427ac3fc102}) + Modbus RTU Master + + + + Modbus slave address + The name of the ParamType (ThingClass: cion, Type: thing, ID: {dac10e08-734c-4e71-a5d6-0d2a1f416ca6}) + Modbus Slave Adresse + + + + Plugged in + The name of the StateType ({13423618-4314-49be-b48c-42d9415199a8}) of ThingClass cion + Eingesteckt + + + + Schrack + The name of the plugin schrack ({600beeb5-5c34-49fc-b2af-8f83c1b11eab}) + Schrack + + + + Schrack GmbH + The name of the vendor ({cadbbbc5-216f-4d25-a8ad-ccf653d1518f}) + Schrack GmbH + + + + Set maximum charging current + The name of the ActionType ({221af869-a796-46c2-a5e0-27c8972a0bf2}) of ThingClass cion + Setze maximalen Ladestrom + + + + i-CHARGE CION + The name of the ThingClass ({075d389d-3330-4d0b-9649-9f085120ca40}) + i-CHARGE CION + + + diff --git a/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-en_US.ts b/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-en_US.ts index da42dcd..105ddf4 100644 --- a/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-en_US.ts +++ b/schrack/translations/600beeb5-5c34-49fc-b2af-8f83c1b11eab-en_US.ts @@ -4,22 +4,17 @@ IntegrationPluginSchrack - - No Modbus RTU interface available. Please set up a Modbus RTU interface first. + + No modbus RTU master with appropriate settings found. Please set up a modbus RTU master with a baudrate of 57600, 8 data bis, 1 stop bit and no parity first. - - The Modbus slave address must be a value between 1 and 254. - - - - + The Modbus address not valid. It must be a value between 1 and 254. - + The Modbus RTU resource is not available. @@ -27,160 +22,85 @@ schrack - - + Charging - The name of the ParamType (ThingClass: cion, EventType: charging, ID: {b59b4b4d-2cdb-4534-bf86-90123ae9bb1a}) ----------- -The name of the StateType ({b59b4b4d-2cdb-4534-bf86-90123ae9bb1a}) of ThingClass cion + The name of the StateType ({b59b4b4d-2cdb-4534-bf86-90123ae9bb1a}) of ThingClass cion - - - + + Charging enabled The name of the ParamType (ThingClass: cion, ActionType: power, ID: {61aea53a-bf8d-4fe6-859a-f1687e15d190}) ---------- -The name of the ParamType (ThingClass: cion, EventType: power, ID: {61aea53a-bf8d-4fe6-859a-f1687e15d190}) ----------- The name of the StateType ({61aea53a-bf8d-4fe6-859a-f1687e15d190}) of ThingClass cion - - Charging enabled or disabled - The name of the EventType ({61aea53a-bf8d-4fe6-859a-f1687e15d190}) of ThingClass cion - - - - - Charging started or stopped - The name of the EventType ({b59b4b4d-2cdb-4534-bf86-90123ae9bb1a}) of ThingClass cion - - - - - + Connected - The name of the ParamType (ThingClass: cion, EventType: connected, ID: {b7aa8e49-a6c0-4b48-b65e-47259686185f}) ----------- -The name of the StateType ({b7aa8e49-a6c0-4b48-b65e-47259686185f}) of ThingClass cion + The name of the StateType ({b7aa8e49-a6c0-4b48-b65e-47259686185f}) of ThingClass cion - - Connected changed - The name of the EventType ({b7aa8e49-a6c0-4b48-b65e-47259686185f}) of ThingClass cion - - - - - - Current power consumption - The name of the ParamType (ThingClass: cion, EventType: currentPower, ID: {db5c951f-47e0-4cdc-8b8b-285f7ed95285}) ----------- -The name of the StateType ({db5c951f-47e0-4cdc-8b8b-285f7ed95285}) of ThingClass cion - - - - - Current power consumption changed - The name of the EventType ({db5c951f-47e0-4cdc-8b8b-285f7ed95285}) of ThingClass cion - - - - + Enable or disable charging The name of the ActionType ({61aea53a-bf8d-4fe6-859a-f1687e15d190}) of ThingClass cion - - - + + Firmware version + The name of the StateType ({33780b19-4855-4b5c-bd84-cec8400309be}) of ThingClass cion + + + + + Maximum charging current The name of the ParamType (ThingClass: cion, ActionType: maxChargingCurrent, ID: {221af869-a796-46c2-a5e0-27c8972a0bf2}) ---------- -The name of the ParamType (ThingClass: cion, EventType: maxChargingCurrent, ID: {221af869-a796-46c2-a5e0-27c8972a0bf2}) ----------- The name of the StateType ({221af869-a796-46c2-a5e0-27c8972a0bf2}) of ThingClass cion - - Maximum charging current changed - The name of the EventType ({221af869-a796-46c2-a5e0-27c8972a0bf2}) of ThingClass cion - - - - + Modbus RTU master The name of the ParamType (ThingClass: cion, Type: thing, ID: {636241a9-4838-48ae-bcc8-3427ac3fc102}) - + Modbus slave address The name of the ParamType (ThingClass: cion, Type: thing, ID: {dac10e08-734c-4e71-a5d6-0d2a1f416ca6}) - - + Plugged in - The name of the ParamType (ThingClass: cion, EventType: pluggedIn, ID: {13423618-4314-49be-b48c-42d9415199a8}) ----------- -The name of the StateType ({13423618-4314-49be-b48c-42d9415199a8}) of ThingClass cion + The name of the StateType ({13423618-4314-49be-b48c-42d9415199a8}) of ThingClass cion - - Plugged or unplugged - The name of the EventType ({13423618-4314-49be-b48c-42d9415199a8}) of ThingClass cion - - - - + Schrack The name of the plugin schrack ({600beeb5-5c34-49fc-b2af-8f83c1b11eab}) - + Schrack GmbH The name of the vendor ({cadbbbc5-216f-4d25-a8ad-ccf653d1518f}) - + Set maximum charging current The name of the ActionType ({221af869-a796-46c2-a5e0-27c8972a0bf2}) of ThingClass cion - - Slave address - The name of the ParamType (ThingClass: cion, Type: discovery, ID: {8004705f-0e13-4713-b75e-49d115cd9517}) - - - - - - Total consumed energy - The name of the ParamType (ThingClass: cion, EventType: totalEnergyConsumed, ID: {8390c005-a8ba-4db6-bb94-8f765ddcc784}) ----------- -The name of the StateType ({8390c005-a8ba-4db6-bb94-8f765ddcc784}) of ThingClass cion - - - - - Total consumed energy changed - The name of the EventType ({8390c005-a8ba-4db6-bb94-8f765ddcc784}) of ThingClass cion - - - - + i-CHARGE CION The name of the ThingClass ({075d389d-3330-4d0b-9649-9f085120ca40}) From 60a48fd3b4cfd22a4dc2e7fb8024a7dec49205e9 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 7 Mar 2023 17:21:03 +0100 Subject: [PATCH 4/4] Fix corner cases in schrack plugins --- schrack/integrationpluginschrack.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/schrack/integrationpluginschrack.cpp b/schrack/integrationpluginschrack.cpp index 94d5cdb..9be9271 100644 --- a/schrack/integrationpluginschrack.cpp +++ b/schrack/integrationpluginschrack.cpp @@ -136,6 +136,12 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info) // Note: This register really only tells us if we can control anything... i.e. if the wallbox is unlocked via RFID connect(cionConnection, &CionModbusRtuConnection::chargingEnabledChanged, thing, [=](quint16 charging){ qCDebug(dcSchrack()) << "Charge control enabled changed:" << charging; + // If this register goes 0->1 it means charging has been started. This could be because of an RFID tag. + // As we have may set charging current to 0 ourselves, we'll want to activate it again here + uint maxSetPoint = thing->stateValue(cionMaxChargingCurrentStateTypeId).toUInt(); + if (cionConnection->chargingCurrentSetpoint() != maxSetPoint) { + cionConnection->setChargingCurrentSetpoint(maxSetPoint); + } }); // We can write chargingCurrentSetpoint to the preferred charging we want, and the wallbox will take it, @@ -153,8 +159,11 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info) connect(cionConnection, &CionModbusRtuConnection::currentChargingCurrentE3Changed, thing, [=](quint16 currentChargingCurrentE3){ qCDebug(dcSchrack()) << "Current charging current E3 current changed:" << currentChargingCurrentE3; - if (cionConnection->chargingCurrentSetpoint() > 0) { + if (cionConnection->chargingEnabled() == 1 && cionConnection->chargingCurrentSetpoint() > 0) { thing->setStateValue(cionMaxChargingCurrentStateTypeId, currentChargingCurrentE3); + thing->setStateValue(cionPowerStateTypeId, true); + } else { + thing->setStateValue(cionPowerStateTypeId, false); } });