Merge PR #40: Update wallbox interface states
commit
595d490e30
|
|
@ -82,7 +82,7 @@
|
||||||
"displayName": "Charging current",
|
"displayName": "Charging current",
|
||||||
"displayNameEvent": "Charging current changed",
|
"displayNameEvent": "Charging current changed",
|
||||||
"displayNameAction": "Set charging current",
|
"displayNameAction": "Set charging current",
|
||||||
"type": "double",
|
"type": "uint",
|
||||||
"unit": "Ampere",
|
"unit": "Ampere",
|
||||||
"minValue": 6,
|
"minValue": 6,
|
||||||
"maxValue": 80,
|
"maxValue": 80,
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
|
||||||
thing->setStateValue(liveWallboxPowerActionTypeId, enabled);
|
thing->setStateValue(liveWallboxPowerActionTypeId, enabled);
|
||||||
int ampere = 0;
|
int ampere = 0;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
ampere = thing->stateValue(liveWallboxMaxChargingCurrentStateTypeId).toInt();
|
ampere = thing->stateValue(liveWallboxMaxChargingCurrentStateTypeId).toUInt();
|
||||||
}
|
}
|
||||||
QUuid requestId = connection->setChargeCurrent(ampere);
|
QUuid requestId = connection->setChargeCurrent(ampere);
|
||||||
if (requestId.isNull()) {
|
if (requestId.isNull()) {
|
||||||
|
|
@ -218,7 +218,7 @@ void IntegrationPluginWebasto::executeAction(ThingActionInfo *info)
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
}
|
}
|
||||||
} else if (action.actionTypeId() == liveWallboxMaxChargingCurrentActionTypeId) {
|
} else if (action.actionTypeId() == liveWallboxMaxChargingCurrentActionTypeId) {
|
||||||
int ampere = action.paramValue(liveWallboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toInt();
|
int ampere = action.paramValue(liveWallboxMaxChargingCurrentActionMaxChargingCurrentParamTypeId).toUInt();
|
||||||
thing->setStateValue(liveWallboxMaxChargingCurrentStateTypeId, ampere);
|
thing->setStateValue(liveWallboxMaxChargingCurrentStateTypeId, ampere);
|
||||||
QUuid requestId = connection->setChargeCurrent(ampere);
|
QUuid requestId = connection->setChargeCurrent(ampere);
|
||||||
if (requestId.isNull()) {
|
if (requestId.isNull()) {
|
||||||
|
|
@ -266,6 +266,27 @@ void IntegrationPluginWebasto::update(Webasto *webasto)
|
||||||
webasto->getRegister(Webasto::TqUserId, 10);
|
webasto->getRegister(Webasto::TqUserId, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginWebasto::evaluatePhaseCount(Thing *thing)
|
||||||
|
{
|
||||||
|
uint amperePhase1 = thing->stateValue(liveWallboxCurrentPhase1StateTypeId).toUInt();
|
||||||
|
uint amperePhase2 = thing->stateValue(liveWallboxCurrentPhase2StateTypeId).toUInt();
|
||||||
|
uint amperePhase3 = thing->stateValue(liveWallboxCurrentPhase3StateTypeId).toUInt();
|
||||||
|
// Check how many phases are actually charging, and update the phase count only if something happens on the phases (current or power)
|
||||||
|
if (!(amperePhase1 == 0 && amperePhase2 == 0 && amperePhase3 == 0)) {
|
||||||
|
uint phaseCount = 0;
|
||||||
|
if (amperePhase1 != 0)
|
||||||
|
phaseCount += 1;
|
||||||
|
|
||||||
|
if (amperePhase2 != 0)
|
||||||
|
phaseCount += 1;
|
||||||
|
|
||||||
|
if (amperePhase3 != 0)
|
||||||
|
phaseCount += 1;
|
||||||
|
|
||||||
|
thing->setStateValue(liveWallboxPhaseCountStateTypeId, phaseCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IntegrationPluginWebasto::onConnectionChanged(bool connected)
|
void IntegrationPluginWebasto::onConnectionChanged(bool connected)
|
||||||
{
|
{
|
||||||
Webasto *connection = static_cast<Webasto *>(sender());
|
Webasto *connection = static_cast<Webasto *>(sender());
|
||||||
|
|
@ -339,6 +360,8 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
thing->setStateValue(liveWallboxChargePointStateStateTypeId, "User not authorized (car attached)");
|
thing->setStateValue(liveWallboxChargePointStateStateTypeId, "User not authorized (car attached)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thing->setStateValue(liveWallboxChargingStateTypeId, Webasto::ChargePointState(data[0]) == Webasto::ChargePointStateCharging);
|
||||||
break;
|
break;
|
||||||
case Webasto::TqChargeState:
|
case Webasto::TqChargeState:
|
||||||
qCDebug(dcWebasto()) << " - Charge state:" << data[0];
|
qCDebug(dcWebasto()) << " - Charge state:" << data[0];
|
||||||
|
|
@ -351,15 +374,19 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
switch (Webasto::CableState(data[0])) {
|
switch (Webasto::CableState(data[0])) {
|
||||||
case Webasto::CableStateNoCableAttached:
|
case Webasto::CableStateNoCableAttached:
|
||||||
thing->setStateValue(liveWallboxCableStateStateTypeId, "No cable attached");
|
thing->setStateValue(liveWallboxCableStateStateTypeId, "No cable attached");
|
||||||
|
thing->setStateValue(liveWallboxPluggedInStateTypeId, false);
|
||||||
break;
|
break;
|
||||||
case Webasto::CableStateCableAttachedNoCarAttached:
|
case Webasto::CableStateCableAttachedNoCarAttached:
|
||||||
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached but no car attached)");
|
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached but no car attached)");
|
||||||
|
thing->setStateValue(liveWallboxPluggedInStateTypeId, false);
|
||||||
break;
|
break;
|
||||||
case Webasto::CableStateCableAttachedCarAttached:
|
case Webasto::CableStateCableAttachedCarAttached:
|
||||||
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached and car attached");
|
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached and car attached");
|
||||||
|
thing->setStateValue(liveWallboxPluggedInStateTypeId, true);
|
||||||
break;
|
break;
|
||||||
case Webasto::CableStateCableAttachedCarAttachedLockActive:
|
case Webasto::CableStateCableAttachedCarAttachedLockActive:
|
||||||
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached, car attached and lock active");
|
thing->setStateValue(liveWallboxCableStateStateTypeId, "Cable attached, car attached and lock active");
|
||||||
|
thing->setStateValue(liveWallboxPluggedInStateTypeId, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -370,14 +397,17 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
case Webasto::TqCurrentL1:
|
case Webasto::TqCurrentL1:
|
||||||
qCDebug(dcWebasto()) << " - Current L1:" << data[0];
|
qCDebug(dcWebasto()) << " - Current L1:" << data[0];
|
||||||
thing->setStateValue(liveWallboxCurrentPhase1StateTypeId, data[0]);
|
thing->setStateValue(liveWallboxCurrentPhase1StateTypeId, data[0]);
|
||||||
|
evaluatePhaseCount(thing);
|
||||||
break;
|
break;
|
||||||
case Webasto::TqCurrentL2:
|
case Webasto::TqCurrentL2:
|
||||||
qCDebug(dcWebasto()) << " - Current L2:" << data[0];
|
qCDebug(dcWebasto()) << " - Current L2:" << data[0];
|
||||||
thing->setStateValue(liveWallboxCurrentPhase2StateTypeId, data[0]);
|
thing->setStateValue(liveWallboxCurrentPhase2StateTypeId, data[0]);
|
||||||
|
evaluatePhaseCount(thing);
|
||||||
break;
|
break;
|
||||||
case Webasto::TqCurrentL3:
|
case Webasto::TqCurrentL3:
|
||||||
qCDebug(dcWebasto()) << " - Current L3:" << data[0];
|
qCDebug(dcWebasto()) << " - Current L3:" << data[0];
|
||||||
thing->setStateValue(liveWallboxCurrentPhase3StateTypeId, data[0]);
|
thing->setStateValue(liveWallboxCurrentPhase3StateTypeId, data[0]);
|
||||||
|
evaluatePhaseCount(thing);
|
||||||
break;
|
break;
|
||||||
case Webasto::TqActivePower: {
|
case Webasto::TqActivePower: {
|
||||||
if (data.count() < 2)
|
if (data.count() < 2)
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ private:
|
||||||
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
||||||
|
|
||||||
void update(Webasto *webasto);
|
void update(Webasto *webasto);
|
||||||
|
void evaluatePhaseCount(Thing *thing);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnectionChanged(bool connected);
|
void onConnectionChanged(bool connected);
|
||||||
|
|
|
||||||
|
|
@ -91,13 +91,39 @@
|
||||||
"displayName": "Charging current",
|
"displayName": "Charging current",
|
||||||
"displayNameAction": "Set charging current",
|
"displayNameAction": "Set charging current",
|
||||||
"displayNameEvent": "Charging current changed",
|
"displayNameEvent": "Charging current changed",
|
||||||
"type": "double",
|
"type": "uint",
|
||||||
"unit": "Ampere",
|
"unit": "Ampere",
|
||||||
"minValue": 6.00,
|
"minValue": 6,
|
||||||
"maxValue": 80.00,
|
"maxValue": 80,
|
||||||
"defaultValue": 6.00,
|
"defaultValue": 6,
|
||||||
"writable": true
|
"writable": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "0e15e78e-a233-4026-a0fd-f65edc824f1e",
|
||||||
|
"name": "pluggedIn",
|
||||||
|
"displayName": "Car plugged in",
|
||||||
|
"displayNameEvent": "Car plugged in changed",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8f35404d-8237-4ff8-8774-9ad10ceee5c3",
|
||||||
|
"name": "charging",
|
||||||
|
"displayName": "Charging",
|
||||||
|
"displayNameEvent": "Charging changed",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "179e6136-2ac1-4247-b457-f804e2212293",
|
||||||
|
"name": "phaseCount",
|
||||||
|
"displayName": "Number of connected phases",
|
||||||
|
"displayNameEvent": "Number of connected phases changed",
|
||||||
|
"type": "uint",
|
||||||
|
"minValue": 1,
|
||||||
|
"maxValue": 3,
|
||||||
|
"defaultValue": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "2027fbb6-c9d2-4a75-bdd0-a3ad3785cdc6",
|
"id": "2027fbb6-c9d2-4a75-bdd0-a3ad3785cdc6",
|
||||||
"name": "currentPhase1",
|
"name": "currentPhase1",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue