Merge PR #225: Update EV charger interface and add full charging current resolution

This commit is contained in:
jenkins 2026-01-12 10:48:20 +01:00
commit 5d14f3a932
16 changed files with 70 additions and 49 deletions

View File

@ -201,7 +201,7 @@ void IntegrationPluginAmperfied::executeAction(ThingActionInfo *info)
if (info->action().actionTypeId() == energyControlPowerActionTypeId) { if (info->action().actionTypeId() == energyControlPowerActionTypeId) {
bool power = info->action().paramValue(energyControlPowerActionPowerParamTypeId).toBool(); bool power = info->action().paramValue(energyControlPowerActionPowerParamTypeId).toBool();
ModbusRtuReply *reply = connection->setChargingCurrent(power ? info->thing()->stateValue(energyControlMaxChargingCurrentStateTypeId).toUInt() * 10 : 0); ModbusRtuReply *reply = connection->setChargingCurrent(power ? static_cast<quint16>(qRound(info->thing()->stateValue(energyControlMaxChargingCurrentStateTypeId).toDouble() * 10)) : 0);
connect(reply, &ModbusRtuReply::finished, info, [info, reply, power](){ connect(reply, &ModbusRtuReply::finished, info, [info, reply, power](){
if (reply->error() == ModbusRtuReply::NoError) { if (reply->error() == ModbusRtuReply::NoError) {
info->thing()->setStateValue(energyControlPowerStateTypeId, power); info->thing()->setStateValue(energyControlPowerStateTypeId, power);
@ -216,11 +216,11 @@ void IntegrationPluginAmperfied::executeAction(ThingActionInfo *info)
if (info->action().actionTypeId() == energyControlMaxChargingCurrentActionTypeId) { if (info->action().actionTypeId() == energyControlMaxChargingCurrentActionTypeId) {
bool power = info->thing()->stateValue(energyControlPowerStateTypeId).toBool(); bool power = info->thing()->stateValue(energyControlPowerStateTypeId).toBool();
uint max = info->action().paramValue(energyControlMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt() * 10; double current = qRound(info->action().paramValue(energyControlMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble() * 10) / 10.0;
ModbusRtuReply *reply = connection->setChargingCurrent(power ? max : 0); ModbusRtuReply *reply = connection->setChargingCurrent(power ? static_cast<quint16>(qRound(current * 10)) : 0);
connect(reply, &ModbusRtuReply::finished, info, [info, reply, max](){ connect(reply, &ModbusRtuReply::finished, info, [info, reply, current](){
if (reply->error() == ModbusRtuReply::NoError) { if (reply->error() == ModbusRtuReply::NoError) {
info->thing()->setStateValue(energyControlMaxChargingCurrentStateTypeId, max / 10); info->thing()->setStateValue(energyControlMaxChargingCurrentStateTypeId, current);
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} else { } else {
qCWarning(dcAmperfied()) << "Error setting power:" << reply->error() << reply->errorString(); qCWarning(dcAmperfied()) << "Error setting power:" << reply->error() << reply->errorString();
@ -241,8 +241,8 @@ void IntegrationPluginAmperfied::executeAction(ThingActionInfo *info)
if (actionType.name() == "power") { if (actionType.name() == "power") {
bool power = info->action().paramValue(actionType.paramTypes().findByName("power").id()).toBool(); bool power = info->action().paramValue(actionType.paramTypes().findByName("power").id()).toBool();
uint max = info->thing()->stateValue("maxChargingCurrent").toUInt(); double current = info->thing()->stateValue("maxChargingCurrent").toDouble();
QModbusReply *reply = connection->setChargingCurrent(power ? max * 10 : 0); QModbusReply *reply = connection->setChargingCurrent(power ? static_cast<quint16>(qRound(current * 10)) : 0);
connect(reply, &QModbusReply::finished, info, [info, reply, power](){ connect(reply, &QModbusReply::finished, info, [info, reply, power](){
if (reply->error() == QModbusDevice::NoError) { if (reply->error() == QModbusDevice::NoError) {
info->thing()->setStateValue("power", power); info->thing()->setStateValue("power", power);
@ -254,11 +254,11 @@ void IntegrationPluginAmperfied::executeAction(ThingActionInfo *info)
}); });
} else if (actionType.name() == "maxChargingCurrent") { } else if (actionType.name() == "maxChargingCurrent") {
bool power = info->thing()->stateValue("power").toBool(); bool power = info->thing()->stateValue("power").toBool();
uint max = info->action().paramValue(actionType.paramTypes().findByName("maxChargingCurrent").id()).toUInt(); double current = info->action().paramValue(actionType.paramTypes().findByName("maxChargingCurrent").id()).toDouble();
QModbusReply *reply = connection->setChargingCurrent(power ? max * 10 : 0); QModbusReply *reply = connection->setChargingCurrent(power ?static_cast<quint16>(qRound(current * 10)): 0);
connect(reply, &QModbusReply::finished, info, [info, reply, max](){ connect(reply, &QModbusReply::finished, info, [info, reply, current](){
if (reply->error() == QModbusDevice::NoError) { if (reply->error() == QModbusDevice::NoError) {
info->thing()->setStateValue("maxChargingCurrent", max / 10); info->thing()->setStateValue("maxChargingCurrent", current);
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} else { } else {
qCWarning(dcAmperfied()) << "Error setting power:" << reply->error() << reply->errorString(); qCWarning(dcAmperfied()) << "Error setting power:" << reply->error() << reply->errorString();
@ -357,7 +357,7 @@ void IntegrationPluginAmperfied::setupRtuConnection(ThingSetupInfo *info)
thing->setStateValue(energyControlPowerStateTypeId, false); thing->setStateValue(energyControlPowerStateTypeId, false);
} else { } else {
thing->setStateValue(energyControlPowerStateTypeId, true); thing->setStateValue(energyControlPowerStateTypeId, true);
thing->setStateValue(energyControlMaxChargingCurrentStateTypeId, connection->chargingCurrent() / 10); thing->setStateValue(energyControlMaxChargingCurrentStateTypeId, connection->chargingCurrent() / 10.0);
} }
thing->setStateMinMaxValues(energyControlMaxChargingCurrentStateTypeId, connection->minChargingCurrent(), connection->maxChargingCurrent()); thing->setStateMinMaxValues(energyControlMaxChargingCurrentStateTypeId, connection->minChargingCurrent(), connection->maxChargingCurrent());
thing->setStateValue(energyControlCurrentPowerStateTypeId, connection->currentPower()); thing->setStateValue(energyControlCurrentPowerStateTypeId, connection->currentPower());
@ -446,7 +446,7 @@ void IntegrationPluginAmperfied::setupTcpConnection(ThingSetupInfo *info)
thing->setStateValue("power", false); thing->setStateValue("power", false);
} else { } else {
thing->setStateValue("power", true); thing->setStateValue("power", true);
thing->setStateValue("maxChargingCurrent", connection->chargingCurrent() / 10); thing->setStateValue("maxChargingCurrent", connection->chargingCurrent() / 10.0);
} }
thing->setStateMinMaxValues("maxChargingCurrent", connection->minChargingCurrent(), connection->maxChargingCurrent()); thing->setStateMinMaxValues("maxChargingCurrent", connection->minChargingCurrent(), connection->maxChargingCurrent());
thing->setStateValue("currentPower", connection->currentPower()); thing->setStateValue("currentPower", connection->currentPower());

View File

@ -98,10 +98,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -212,10 +213,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -337,10 +339,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -462,10 +465,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },

View File

@ -217,7 +217,7 @@ void IntegrationPluginInro::executeAction(ThingActionInfo *info)
} }
if (info->action().actionTypeId() == pantaboxMaxChargingCurrentActionTypeId) { if (info->action().actionTypeId() == pantaboxMaxChargingCurrentActionTypeId) {
quint16 chargingCurrent = info->action().paramValue(pantaboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); quint16 chargingCurrent = static_cast<quint16>(qRound(info->action().paramValue(pantaboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
qCDebug(dcInro()) << "PANTABOX: Set max charging current" << chargingCurrent << "A"; qCDebug(dcInro()) << "PANTABOX: Set max charging current" << chargingCurrent << "A";
QModbusReply *reply = connection->setMaxChargingCurrent(chargingCurrent); QModbusReply *reply = connection->setMaxChargingCurrent(chargingCurrent);

View File

@ -108,10 +108,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 16, "maxValue": 16,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },

View File

@ -320,8 +320,8 @@ void IntegrationPluginMennekes::executeAction(ThingActionInfo *info)
if (info->action().actionTypeId() == amtronECUPowerActionTypeId) { if (info->action().actionTypeId() == amtronECUPowerActionTypeId) {
bool power = info->action().paramValue(amtronECUPowerActionPowerParamTypeId).toBool(); bool power = info->action().paramValue(amtronECUPowerActionPowerParamTypeId).toBool();
int maxChargingCurrent = info->thing()->stateValue(amtronECUMaxChargingCurrentStateTypeId).toUInt(); double maxChargingCurrent = info->thing()->stateValue(amtronECUMaxChargingCurrentStateTypeId).toDouble();
int effectiveCurrent = power ? maxChargingCurrent : 0; int effectiveCurrent = power ? qRound(maxChargingCurrent) : 0;
qCInfo(dcMennekes()) << "Executing power action:" << power << "max current:" << maxChargingCurrent << "-> effective current" << effectiveCurrent; qCInfo(dcMennekes()) << "Executing power action:" << power << "max current:" << maxChargingCurrent << "-> effective current" << effectiveCurrent;
QModbusReply *reply = amtronECUConnection->setHemsCurrentLimit(effectiveCurrent); QModbusReply *reply = amtronECUConnection->setHemsCurrentLimit(effectiveCurrent);
if (!reply) { if (!reply) {
@ -344,7 +344,7 @@ void IntegrationPluginMennekes::executeAction(ThingActionInfo *info)
if (info->action().actionTypeId() == amtronECUMaxChargingCurrentActionTypeId) { if (info->action().actionTypeId() == amtronECUMaxChargingCurrentActionTypeId) {
bool power = info->thing()->stateValue(amtronECUPowerStateTypeId).toBool(); bool power = info->thing()->stateValue(amtronECUPowerStateTypeId).toBool();
int maxChargingCurrent = info->action().paramValue(amtronECUMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt(); int maxChargingCurrent = qRound(info->action().paramValue(amtronECUMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble());
int effectiveCurrent = power ? maxChargingCurrent : 0; int effectiveCurrent = power ? maxChargingCurrent : 0;
qCInfo(dcMennekes()) << "Executing max current action:" << maxChargingCurrent << "Power is" << power << "-> effective:" << effectiveCurrent; qCInfo(dcMennekes()) << "Executing max current action:" << maxChargingCurrent << "Power is" << power << "-> effective:" << effectiveCurrent;
QModbusReply *reply = amtronECUConnection->setHemsCurrentLimit(effectiveCurrent); QModbusReply *reply = amtronECUConnection->setHemsCurrentLimit(effectiveCurrent);
@ -443,8 +443,8 @@ void IntegrationPluginMennekes::executeAction(ThingActionInfo *info)
}); });
} }
if (info->action().actionTypeId() == amtronCompact20MaxChargingCurrentActionTypeId) { if (info->action().actionTypeId() == amtronCompact20MaxChargingCurrentActionTypeId) {
int maxChargingCurrent = info->action().paramValue(amtronCompact20MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt(); double maxChargingCurrent = info->action().paramValue(amtronCompact20MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble();
float value = maxChargingCurrent; float value = static_cast<float>(maxChargingCurrent);
// Note: in firmwares up to 1.0.2 there's an issue that it cannot be exactly 6A, must be 6.01 or so // Note: in firmwares up to 1.0.2 there's an issue that it cannot be exactly 6A, must be 6.01 or so
if (maxChargingCurrent == 6) { if (maxChargingCurrent == 6) {

View File

@ -107,10 +107,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -244,10 +245,11 @@
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameEvent": "Maximum charging current changed", "displayNameEvent": "Maximum charging current changed",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
} }
@ -360,10 +362,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.01,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },

View File

@ -223,7 +223,7 @@ void IntegrationPluginPcElectric::executeAction(ThingActionInfo *info)
} else if (info->action().actionTypeId() == ev11MaxChargingCurrentActionTypeId) { } else if (info->action().actionTypeId() == ev11MaxChargingCurrentActionTypeId) {
uint desiredChargingCurrent = info->action().paramValue(ev11MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); double desiredChargingCurrent = info->action().paramValue(ev11MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble();
qCDebug(dcPcElectric()) << "Set max charging current to" << desiredChargingCurrent << "A"; qCDebug(dcPcElectric()) << "Set max charging current to" << desiredChargingCurrent << "A";
// Update buffer // Update buffer

View File

@ -126,11 +126,12 @@
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameEvent": "Maximum charging current changed", "displayNameEvent": "Maximum charging current changed",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"defaultValue": 6, "defaultValue": 6,
"minValue": 6, "minValue": 6,
"maxValue": 16, "maxValue": 16,
"stepSize": 0.01,
"writable": true "writable": true
}, },
{ {

View File

@ -186,7 +186,7 @@ void IntegrationPluginPhoenixConnect::setupThing(ThingSetupInfo *info)
connect(connection, &PhoenixModbusTcpConnection::maximumChargingCurrentChanged, thing, [thing](quint16 maxChargingCurrent) { connect(connection, &PhoenixModbusTcpConnection::maximumChargingCurrentChanged, thing, [thing](quint16 maxChargingCurrent) {
qCDebug(dcPhoenixConnect()) << "Max charging current changed" << maxChargingCurrent; qCDebug(dcPhoenixConnect()) << "Max charging current changed" << maxChargingCurrent;
thing->setStateValue("maxChargingCurrent", 1.0 * maxChargingCurrent / 10); // 100mA -> 1A thing->setStateValue("maxChargingCurrent", maxChargingCurrent / 10.0); // 100mA -> 1A
}); });
connect(connection, &PhoenixModbusTcpConnection::activePowerChanged, thing, [thing](quint32 activePower) { connect(connection, &PhoenixModbusTcpConnection::activePowerChanged, thing, [thing](quint32 activePower) {
@ -262,7 +262,8 @@ void IntegrationPluginPhoenixConnect::executeAction(ThingActionInfo *info)
}); });
} else if (actionType.name() == "maxChargingCurrent") { } else if (actionType.name() == "maxChargingCurrent") {
uint16_t current = action.param(actionType.id()).value().toUInt(); double current = qRound(action.param(actionType.id()).value().toDouble() * 10) / 10.0;
qCDebug(dcPhoenixConnect()) << "Charging power set to" << current; qCDebug(dcPhoenixConnect()) << "Charging power set to" << current;
QModbusReply *reply = connection->setMaximumChargingCurrent(current * 10); QModbusReply *reply = connection->setMaximumChargingCurrent(current * 10);
connect(reply, &QModbusReply::finished, info, [info, thing, reply, current](){ connect(reply, &QModbusReply::finished, info, [info, thing, reply, current](){

View File

@ -104,10 +104,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 16, "maxValue": 16,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -217,10 +218,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -366,10 +368,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 16, "maxValue": 16,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -479,10 +482,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -628,10 +632,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 16, "maxValue": 16,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -731,10 +736,11 @@
"displayName": "Charging current", "displayName": "Charging current",
"displayNameEvent": "Charging current changed", "displayNameEvent": "Charging current changed",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 0.1,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },

View File

@ -139,7 +139,7 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
qCDebug(dcSchrack()) << "Charge control enabled changed:" << 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. // 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 // As we have may set charging current to 0 ourselves, we'll want to activate it again here
uint maxSetPoint = thing->stateValue(cionMaxChargingCurrentStateTypeId).toUInt(); quint16 maxSetPoint = static_cast<quint16>(qRound(thing->stateValue(cionMaxChargingCurrentStateTypeId).toDouble()));
if (cionConnection->chargingCurrentSetpoint() != maxSetPoint) { if (cionConnection->chargingCurrentSetpoint() != maxSetPoint) {
cionConnection->setChargingCurrentSetpoint(maxSetPoint); cionConnection->setChargingCurrentSetpoint(maxSetPoint);
} }
@ -293,7 +293,7 @@ void IntegrationPluginSchrack::executeAction(ThingActionInfo *info)
CionModbusRtuConnection *cionConnection = m_cionConnections.value(info->thing()); CionModbusRtuConnection *cionConnection = m_cionConnections.value(info->thing());
if (info->action().actionTypeId() == cionPowerActionTypeId) { if (info->action().actionTypeId() == cionPowerActionTypeId) {
bool enabled = info->action().paramValue(cionPowerActionPowerParamTypeId).toBool(); bool enabled = info->action().paramValue(cionPowerActionPowerParamTypeId).toBool();
int maxChargingCurrent = enabled ? info->thing()->stateValue(cionMaxChargingCurrentStateTypeId).toUInt() : 0; int maxChargingCurrent = enabled ? static_cast<quint16>(qRound(info->thing()->stateValue(cionMaxChargingCurrentStateTypeId).toDouble())) : 0;
qCDebug(dcSchrack()) << "Setting charging enabled:" << (enabled ? 1 : 0) << "(charging current setpoint:" << maxChargingCurrent << ")"; qCDebug(dcSchrack()) << "Setting charging enabled:" << (enabled ? 1 : 0) << "(charging current setpoint:" << maxChargingCurrent << ")";
// Note: If the wallbox has an RFID reader connected, writing register 100 (chargingEnabled) won't work as the RFID // Note: If the wallbox has an RFID reader connected, writing register 100 (chargingEnabled) won't work as the RFID
@ -321,7 +321,7 @@ void IntegrationPluginSchrack::executeAction(ThingActionInfo *info)
} else if (info->action().actionTypeId() == cionMaxChargingCurrentActionTypeId) { } else if (info->action().actionTypeId() == cionMaxChargingCurrentActionTypeId) {
// If charging is set to enabled, we'll write the value to the wallbox // If charging is set to enabled, we'll write the value to the wallbox
uint maxChargingCurrent = info->action().paramValue(cionMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); quint16 maxChargingCurrent = static_cast<quint16>(qRound(info->action().paramValue(cionMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
if (info->thing()->stateValue(cionPowerStateTypeId).toBool()) { if (info->thing()->stateValue(cionPowerStateTypeId).toBool()) {
qCDebug(dcSchrack) << "Charging is enabled. Applying max charging current setpoint of" << maxChargingCurrent << "to wallbox"; qCDebug(dcSchrack) << "Charging is enabled. Applying max charging current setpoint of" << maxChargingCurrent << "to wallbox";
ModbusRtuReply *reply = cionConnection->setChargingCurrentSetpoint(maxChargingCurrent); ModbusRtuReply *reply = cionConnection->setChargingCurrentSetpoint(maxChargingCurrent);

View File

@ -68,11 +68,12 @@
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameEvent": "Maximum charging current changed", "displayNameEvent": "Maximum charging current changed",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"defaultValue": 6, "defaultValue": 6,
"minValue": 1, "minValue": 1,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"writable": true "writable": true
}, },
{ {

View File

@ -187,7 +187,7 @@ void IntegrationPluginVestel::executeAction(ThingActionInfo *info)
// Note: only write the register if power is true, otherwise we would start charging. The state represents the desired current, // Note: only write the register if power is true, otherwise we would start charging. The state represents the desired current,
// once the power is true, the current will be written to the corresponding current. // once the power is true, the current will be written to the corresponding current.
int maxChargingCurrent = info->action().paramValue(evc04MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt(); quint16 maxChargingCurrent = static_cast<quint16>(qRound(info->action().paramValue(evc04MaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
if (info->thing()->stateValue(evc04PowerStateTypeId).toBool()) { if (info->thing()->stateValue(evc04PowerStateTypeId).toBool()) {
qCDebug(dcVestel()) << "Write max charging current" << maxChargingCurrent; qCDebug(dcVestel()) << "Write max charging current" << maxChargingCurrent;

View File

@ -107,10 +107,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },

View File

@ -513,7 +513,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
m_asyncActions.insert(requestId, info); m_asyncActions.insert(requestId, info);
} }
} else if (action.actionTypeId() == webastoLiveMaxChargingCurrentActionTypeId) { } else if (action.actionTypeId() == webastoLiveMaxChargingCurrentActionTypeId) {
int ampere = action.paramValue(webastoLiveMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); quint16 ampere = static_cast<quint16>(qRound(action.paramValue(webastoLiveMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
thing->setStateValue(webastoLiveMaxChargingCurrentStateTypeId, ampere); thing->setStateValue(webastoLiveMaxChargingCurrentStateTypeId, ampere);
QUuid requestId = connection->setChargeCurrent(ampere); QUuid requestId = connection->setChargeCurrent(ampere);
if (requestId.isNull()) { if (requestId.isNull()) {
@ -571,7 +571,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
executeWebastoNextPowerAction(info, power); executeWebastoNextPowerAction(info, power);
} }
} else if (action.actionTypeId() == webastoNextMaxChargingCurrentActionTypeId) { } else if (action.actionTypeId() == webastoNextMaxChargingCurrentActionTypeId) {
quint16 chargingCurrent = action.paramValue(webastoNextMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt(); quint16 chargingCurrent = static_cast<quint16>(qRound(action.paramValue(webastoNextMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
qCDebug(dcWebasto()) << "Set max charging current of" << thing << "to" << chargingCurrent << "ampere"; qCDebug(dcWebasto()) << "Set max charging current of" << thing << "to" << chargingCurrent << "ampere";
QModbusReply *reply = connection->setChargeCurrent(chargingCurrent); QModbusReply *reply = connection->setChargeCurrent(chargingCurrent);
connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater);
@ -620,7 +620,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
}); });
} }
if (info->action().actionTypeId() == webastoUniteMaxChargingCurrentActionTypeId) { if (info->action().actionTypeId() == webastoUniteMaxChargingCurrentActionTypeId) {
int maxChargingCurrent = info->action().paramValue(webastoUniteMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt(); quint16 maxChargingCurrent = static_cast<quint16>(qRound(info->action().paramValue(webastoUniteMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble()));
QModbusReply *reply = evc04Connection->setChargingCurrent(maxChargingCurrent); QModbusReply *reply = evc04Connection->setChargingCurrent(maxChargingCurrent);
connect(reply, &QModbusReply::finished, info, [info, reply, maxChargingCurrent](){ connect(reply, &QModbusReply::finished, info, [info, reply, maxChargingCurrent](){
if (reply->error() == QModbusDevice::NoError) { if (reply->error() == QModbusDevice::NoError) {

View File

@ -96,10 +96,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Charging current", "displayName": "Charging current",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 80, "maxValue": 80,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -297,10 +298,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Charging current", "displayName": "Charging current",
"displayNameAction": "Set charging current", "displayNameAction": "Set charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },
@ -569,10 +571,11 @@
"name": "maxChargingCurrent", "name": "maxChargingCurrent",
"displayName": "Maximum charging current", "displayName": "Maximum charging current",
"displayNameAction": "Set maximum charging current", "displayNameAction": "Set maximum charging current",
"type": "uint", "type": "double",
"unit": "Ampere", "unit": "Ampere",
"minValue": 6, "minValue": 6,
"maxValue": 32, "maxValue": 32,
"stepSize": 1.0,
"defaultValue": 6, "defaultValue": 6,
"writable": true "writable": true
}, },