Set state value before finishing action in order to prevent flickering sliders
This commit is contained in:
parent
b9221ee746
commit
9996d2db9f
@ -288,7 +288,7 @@ void IntegrationPluginGoECharger::executeAction(ThingActionInfo *info)
|
|||||||
qCDebug(dcGoECharger()) << "Setting charging allowed to" << power;
|
qCDebug(dcGoECharger()) << "Setting charging allowed to" << power;
|
||||||
// Set the allow value
|
// Set the allow value
|
||||||
QString configuration = QString("alw=%1").arg(power ? 1: 0);
|
QString configuration = QString("alw=%1").arg(power ? 1: 0);
|
||||||
sendActionRequestV1(thing, info, configuration);
|
sendActionRequestV1(thing, info, configuration, QVariant(power));
|
||||||
return;
|
return;
|
||||||
} else if (action.actionTypeId() == goeHomeMaxChargingCurrentActionTypeId) {
|
} else if (action.actionTypeId() == goeHomeMaxChargingCurrentActionTypeId) {
|
||||||
uint maxChargingCurrent = action.paramValue(goeHomeMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt();
|
uint maxChargingCurrent = action.paramValue(goeHomeMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt();
|
||||||
@ -296,7 +296,7 @@ void IntegrationPluginGoECharger::executeAction(ThingActionInfo *info)
|
|||||||
// FIXME: check if we can use amx since it is better for pv charging, not all version seen implement amx
|
// FIXME: check if we can use amx since it is better for pv charging, not all version seen implement amx
|
||||||
// Maybe check if the user sets it or a automatism
|
// Maybe check if the user sets it or a automatism
|
||||||
QString configuration = QString("amp=%1").arg(maxChargingCurrent);
|
QString configuration = QString("amp=%1").arg(maxChargingCurrent);
|
||||||
sendActionRequestV1(thing, info, configuration);
|
sendActionRequestV1(thing, info, configuration, QVariant(maxChargingCurrent));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
info->finish(Thing::ThingErrorActionTypeNotFound);
|
info->finish(Thing::ThingErrorActionTypeNotFound);
|
||||||
@ -334,8 +334,8 @@ void IntegrationPluginGoECharger::executeAction(ThingActionInfo *info)
|
|||||||
QVariantMap responseCode = jsonDoc.toVariant().toMap();
|
QVariantMap responseCode = jsonDoc.toVariant().toMap();
|
||||||
if (responseCode.value("frc", false).toBool()) {
|
if (responseCode.value("frc", false).toBool()) {
|
||||||
qCDebug(dcGoECharger()) << "Execute action finished successfully. Power" << power;
|
qCDebug(dcGoECharger()) << "Execute action finished successfully. Power" << power;
|
||||||
info->finish(Thing::ThingErrorNoError);
|
|
||||||
thing->setStateValue("power", power);
|
thing->setStateValue("power", power);
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcGoECharger()) << "Action finished with error:" << responseCode.value("frc").toString();
|
qCWarning(dcGoECharger()) << "Action finished with error:" << responseCode.value("frc").toString();
|
||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
@ -373,8 +373,8 @@ void IntegrationPluginGoECharger::executeAction(ThingActionInfo *info)
|
|||||||
QVariantMap responseCode = jsonDoc.toVariant().toMap();
|
QVariantMap responseCode = jsonDoc.toVariant().toMap();
|
||||||
if (responseCode.value("amp", false).toBool()) {
|
if (responseCode.value("amp", false).toBool()) {
|
||||||
qCDebug(dcGoECharger()) << "Execute action finished successfully. Charging current" << ampere;
|
qCDebug(dcGoECharger()) << "Execute action finished successfully. Charging current" << ampere;
|
||||||
info->finish(Thing::ThingErrorNoError);
|
|
||||||
thing->setStateValue("maxChargingCurrent", ampere);
|
thing->setStateValue("maxChargingCurrent", ampere);
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcGoECharger()) << "Action finished with error:" << responseCode.value("amp").toString();
|
qCWarning(dcGoECharger()) << "Action finished with error:" << responseCode.value("amp").toString();
|
||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
@ -656,7 +656,7 @@ QNetworkRequest IntegrationPluginGoECharger::buildConfigurationRequestV1(const Q
|
|||||||
return QNetworkRequest(requestUrl);
|
return QNetworkRequest(requestUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginGoECharger::sendActionRequestV1(Thing *thing, ThingActionInfo *info, const QString &configuration)
|
void IntegrationPluginGoECharger::sendActionRequestV1(Thing *thing, ThingActionInfo *info, const QString &configuration, const QVariant &value)
|
||||||
{
|
{
|
||||||
// Lets use rest here since we get a reply on the rest request.
|
// Lets use rest here since we get a reply on the rest request.
|
||||||
// For using MQTT publish to topic "go-eCharger/<serialnumber>/cmd/req"
|
// For using MQTT publish to topic "go-eCharger/<serialnumber>/cmd/req"
|
||||||
@ -681,6 +681,7 @@ void IntegrationPluginGoECharger::sendActionRequestV1(Thing *thing, ThingActionI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thing->setStateValue(info->action().actionTypeId(), value);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
updateV1(thing, jsonDoc.toVariant().toMap());
|
updateV1(thing, jsonDoc.toVariant().toMap());
|
||||||
});
|
});
|
||||||
|
|||||||
@ -119,7 +119,7 @@ private:
|
|||||||
// API V1
|
// API V1
|
||||||
void updateV1(Thing *thing, const QVariantMap &statusMap);
|
void updateV1(Thing *thing, const QVariantMap &statusMap);
|
||||||
QNetworkRequest buildConfigurationRequestV1(const QHostAddress &address, const QString &configuration);
|
QNetworkRequest buildConfigurationRequestV1(const QHostAddress &address, const QString &configuration);
|
||||||
void sendActionRequestV1(Thing *thing, ThingActionInfo *info, const QString &configuration);
|
void sendActionRequestV1(Thing *thing, ThingActionInfo *info, const QString &configuration, const QVariant &value);
|
||||||
void setupMqttChannelV1(ThingSetupInfo *info, const QHostAddress &address, const QVariantMap &statusMap);
|
void setupMqttChannelV1(ThingSetupInfo *info, const QHostAddress &address, const QVariantMap &statusMap);
|
||||||
void reconfigureMqttChannelV1(Thing *thing, const QVariantMap &statusMap);
|
void reconfigureMqttChannelV1(Thing *thing, const QVariantMap &statusMap);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user