Merge PR #764: EVerest: Add phase switching
This commit is contained in:
commit
5189756c41
@ -133,7 +133,16 @@ void Everest::setMaxChargingCurrent(double current)
|
|||||||
QByteArray payload = QByteArray::number(current);
|
QByteArray payload = QByteArray::number(current);
|
||||||
|
|
||||||
m_client->publish(topic, payload);
|
m_client->publish(topic, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Everest::setMaxChargingCurrentAndPhaseCount(uint phasesCount, double current)
|
||||||
|
{
|
||||||
|
QString topic = m_topicPrefix + "/cmd/set_limit_amps_phases";
|
||||||
|
QVariantMap data;
|
||||||
|
data.insert("amps", current);
|
||||||
|
data.insert("phases", phasesCount);
|
||||||
|
|
||||||
|
m_client->publish(topic, QJsonDocument::fromVariant(data).toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Everest::onConnected()
|
void Everest::onConnected()
|
||||||
@ -207,16 +216,16 @@ void Everest::onPublishReceived(const QString &topic, const QByteArray &payload,
|
|||||||
m_thing->setStateMaxValue(everestMaxChargingCurrentStateTypeId, maxCurrent);
|
m_thing->setStateMaxValue(everestMaxChargingCurrentStateTypeId, maxCurrent);
|
||||||
m_thing->setStateMinValue(everestMaxChargingCurrentStateTypeId, minCurrent == 0 ? 6 : minCurrent);
|
m_thing->setStateMinValue(everestMaxChargingCurrentStateTypeId, minCurrent == 0 ? 6 : minCurrent);
|
||||||
|
|
||||||
// FIXME: once we have a method for phase switching, we can re-enable the featre here
|
bool phaseSwitchingAvailable = dataMap.value("supports_changing_phases_during_charging", false).toBool();
|
||||||
|
if (!phaseSwitchingAvailable) {
|
||||||
// bool phaseSwitchingAvailable = dataMap.value("supports_changing_phases_during_charging", false).toBool();
|
// Only option left is set the desired phase count to 3, force that value
|
||||||
// if (!phaseSwitchingAvailable) {
|
m_thing->setStatePossibleValues(everestDesiredPhaseCountStateTypeId, { 3 });
|
||||||
// // Only option left is set the desired phase count to 3, force that value
|
m_thing->setStateValue(everestDesiredPhaseCountStateTypeId, 3);
|
||||||
// m_thing->setStatePossibleValues(everestDesiredPhaseCountStateTypeId, { 3 });
|
m_thing->setStateValue(everestPhaseCountStateTypeId, 3);
|
||||||
// m_thing->setStateValue(everestDesiredPhaseCountStateTypeId, 3);
|
} else {
|
||||||
// } else {
|
m_thing->setStatePossibleValues(everestDesiredPhaseCountStateTypeId, { 1, 3 });
|
||||||
// m_thing->setStatePossibleValues(everestDesiredPhaseCountStateTypeId, { 1, 3 });
|
m_thing->setStateValue(everestPhaseCountStateTypeId, m_thing->stateValue(everestDesiredPhaseCountStateTypeId));
|
||||||
// }
|
}
|
||||||
|
|
||||||
} else if (topic.endsWith("limits")) {
|
} else if (topic.endsWith("limits")) {
|
||||||
/*
|
/*
|
||||||
@ -227,7 +236,7 @@ void Everest::onPublishReceived(const QString &topic, const QByteArray &payload,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
m_thing->setStateValue(everestPhaseCountStateTypeId, dataMap.value("nr_of_phases_available").toUInt());
|
//m_thing->setStateValue(everestPhaseCountStateTypeId, dataMap.value("nr_of_phases_available").toUInt());
|
||||||
double maxCurrent = dataMap.value("max_current").toDouble();
|
double maxCurrent = dataMap.value("max_current").toDouble();
|
||||||
if (maxCurrent >= 6) {
|
if (maxCurrent >= 6) {
|
||||||
// FIXME: make it a double again once supported from the interface
|
// FIXME: make it a double again once supported from the interface
|
||||||
@ -312,7 +321,6 @@ void Everest::onPublishReceived(const QString &topic, const QByteArray &payload,
|
|||||||
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
m_thing->setStateValue(everestTemperatureStateTypeId, dataMap.value("temperature").toDouble());
|
m_thing->setStateValue(everestTemperatureStateTypeId, dataMap.value("temperature").toDouble());
|
||||||
m_thing->setStateValue(everestFanSpeedStateTypeId, dataMap.value("fan_rpm").toDouble());
|
m_thing->setStateValue(everestFanSpeedStateTypeId, dataMap.value("fan_rpm").toDouble());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,9 +69,12 @@ public:
|
|||||||
void deinitialize();
|
void deinitialize();
|
||||||
|
|
||||||
void enableCharging(bool enable);
|
void enableCharging(bool enable);
|
||||||
|
|
||||||
|
// Use only without phase switching
|
||||||
void setMaxChargingCurrent(double current);
|
void setMaxChargingCurrent(double current);
|
||||||
|
|
||||||
signals:
|
// Use also for setting the charging current if phase switching is available
|
||||||
|
void setMaxChargingCurrentAndPhaseCount(uint phasesCount, double current);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnected();
|
void onConnected();
|
||||||
|
|||||||
@ -264,11 +264,20 @@ void IntegrationPluginEverest::executeAction(ThingActionInfo *info)
|
|||||||
thing->setStateValue(everestPowerStateTypeId, power);
|
thing->setStateValue(everestPowerStateTypeId, power);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else if (info->action().actionTypeId() == everestMaxChargingCurrentActionTypeId) {
|
} else if (info->action().actionTypeId() == everestMaxChargingCurrentActionTypeId) {
|
||||||
|
// Note: once we support phase switching, we cannot use the
|
||||||
|
uint phaseCount = thing->stateValue(everestDesiredPhaseCountStateTypeId).toUInt();
|
||||||
double current = info->action().paramValue(everestMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble();
|
double current = info->action().paramValue(everestMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toDouble();
|
||||||
qCDebug(dcEverest()) << "Setting max charging current to" << current << thing;
|
qCDebug(dcEverest()).nospace() << "Setting max charging current to " << current << "A (Phases: " << phaseCount << ") " << thing;
|
||||||
everest->setMaxChargingCurrent(current);
|
everest->setMaxChargingCurrentAndPhaseCount(phaseCount, current);
|
||||||
thing->setStateValue(everestMaxChargingCurrentStateTypeId, current);
|
thing->setStateValue(everestMaxChargingCurrentStateTypeId, current);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
} else if (info->action().actionTypeId() == everestDesiredPhaseCountActionTypeId) {
|
||||||
|
uint phaseCount = info->action().paramValue(everestDesiredPhaseCountActionDesiredPhaseCountParamTypeId).toUInt();
|
||||||
|
double current = thing->stateValue(everestMaxChargingCurrentStateTypeId).toDouble();
|
||||||
|
qCDebug(dcEverest()).nospace() << "Setting desired phase count to " << phaseCount << " (" << current << "A) " << thing;
|
||||||
|
everest->setMaxChargingCurrentAndPhaseCount(phaseCount, current);
|
||||||
|
thing->setStateValue(everestDesiredPhaseCountStateTypeId, phaseCount);
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -92,6 +92,18 @@
|
|||||||
"maxValue": 3,
|
"maxValue": 3,
|
||||||
"defaultValue": 1
|
"defaultValue": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "1dc5fbff-354b-4a68-aae3-95150b257faa",
|
||||||
|
"name": "desiredPhaseCount",
|
||||||
|
"displayName": "Desired phase count",
|
||||||
|
"displayNameAction": "Set desired phase count",
|
||||||
|
"type": "uint",
|
||||||
|
"minValue": 1,
|
||||||
|
"maxValue": 3,
|
||||||
|
"possibleValues": [1, 3],
|
||||||
|
"writable": true,
|
||||||
|
"defaultValue": 3
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "2104641b-1004-4637-8eca-108f53dcb402",
|
"id": "2104641b-1004-4637-8eca-108f53dcb402",
|
||||||
"name": "connected",
|
"name": "connected",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user