diff --git a/schrack/integrationpluginschrack.cpp b/schrack/integrationpluginschrack.cpp index 1b9a9cb..7874980 100644 --- a/schrack/integrationpluginschrack.cpp +++ b/schrack/integrationpluginschrack.cpp @@ -139,7 +139,7 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info) 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(); + quint16 maxSetPoint = static_cast(qRound(thing->stateValue(cionMaxChargingCurrentStateTypeId).toDouble())); if (cionConnection->chargingCurrentSetpoint() != maxSetPoint) { cionConnection->setChargingCurrentSetpoint(maxSetPoint); } @@ -293,7 +293,7 @@ void IntegrationPluginSchrack::executeAction(ThingActionInfo *info) CionModbusRtuConnection *cionConnection = m_cionConnections.value(info->thing()); if (info->action().actionTypeId() == cionPowerActionTypeId) { bool enabled = info->action().paramValue(cionPowerActionPowerParamTypeId).toBool(); - int maxChargingCurrent = enabled ? info->thing()->stateValue(cionMaxChargingCurrentStateTypeId).toUInt() : 0; + int maxChargingCurrent = enabled ? static_cast(qRound(info->thing()->stateValue(cionMaxChargingCurrentStateTypeId).toDouble())) : 0; 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 @@ -321,7 +321,7 @@ void IntegrationPluginSchrack::executeAction(ThingActionInfo *info) } else if (info->action().actionTypeId() == cionMaxChargingCurrentActionTypeId) { // 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(qRound(info->action().paramValue(cionMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble())); if (info->thing()->stateValue(cionPowerStateTypeId).toBool()) { qCDebug(dcSchrack) << "Charging is enabled. Applying max charging current setpoint of" << maxChargingCurrent << "to wallbox"; ModbusRtuReply *reply = cionConnection->setChargingCurrentSetpoint(maxChargingCurrent); diff --git a/schrack/integrationpluginschrack.json b/schrack/integrationpluginschrack.json index 62550d6..77c3fc4 100644 --- a/schrack/integrationpluginschrack.json +++ b/schrack/integrationpluginschrack.json @@ -68,11 +68,12 @@ "displayName": "Maximum charging current", "displayNameEvent": "Maximum charging current changed", "displayNameAction": "Set maximum charging current", - "type": "uint", + "type": "double", "unit": "Ampere", "defaultValue": 6, "minValue": 1, "maxValue": 32, + "stepSize": 1.0, "writable": true }, {