Scrack: Improve debug prints

pull/76/head
Michael Zanetti 2022-08-03 13:00:53 +02:00
parent 84c13bc562
commit 93b31ce127
3 changed files with 28 additions and 10 deletions

View File

@ -107,7 +107,7 @@
"type": "uint16",
"registerType": "holdingRegister",
"readSchedule": "update",
"description": "Mode3-State A, B, C, D, U",
"description": "Status bits",
"defaultValue": 85,
"access": "R"
},
@ -118,7 +118,7 @@
"type": "uint16",
"registerType": "holdingRegister",
"readSchedule": "update",
"description": "Status bits",
"description": "CP Status bits",
"defaultValue": 0,
"access": "R"
},

View File

@ -98,7 +98,7 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
// Note: This register really only tells us if we can control anything... i.e. if the wallbox is unlocked via RFID
connect(cionConnection, &CionModbusRtuConnection::chargingEnabledChanged, thing, [=](quint16 charging){
qCDebug(dcSchrack()) << "Charging enabled changed:" << charging;
qCInfo(dcSchrack()) << "Charge control enabled changed:" << charging;
});
// We can write chargingCurrentSetpoint to the preferred charging we want, and the wallbox will take it,
@ -106,16 +106,16 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
// We'll use that for setting our state, just monitoring this one on the logs
// Setting this to 0 will pause charging, anything else will control the charging (and return the actual value in currentChargingCurrentE3)
connect(cionConnection, &CionModbusRtuConnection::chargingCurrentSetpointChanged, thing, [=](quint16 chargingCurrentSetpoint){
qCDebug(dcSchrack()) << "Charging current setpoint changed:" << chargingCurrentSetpoint;
qCInfo(dcSchrack()) << "Charging current setpoint changed:" << chargingCurrentSetpoint;
});
connect(cionConnection, &CionModbusRtuConnection::cpSignalStateChanged, thing, [=](quint16 cpSignalState){
qCDebug(dcSchrack()) << "CP Signal state changed:" << (char)cpSignalState;
qCInfo(dcSchrack()) << "CP Signal state changed:" << (char)cpSignalState;
thing->setStateValue(cionPluggedInStateTypeId, cpSignalState >= 66);
});
connect(cionConnection, &CionModbusRtuConnection::currentChargingCurrentE3Changed, thing, [=](quint16 currentChargingCurrentE3){
qCDebug(dcSchrack()) << "Current charging current E3 current changed:" << currentChargingCurrentE3;
qCInfo(dcSchrack()) << "Current charging current E3 current changed:" << currentChargingCurrentE3;
if (cionConnection->chargingCurrentSetpoint() > 0) {
thing->setStateValue(cionMaxChargingCurrentStateTypeId, currentChargingCurrentE3);
}
@ -124,19 +124,21 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
// The maxChargingCurrentE3 takes into account the DIP switches and connected cable, so this is effectively
// our maximum. However, it will go to 0 when unplugged, which is odd, so we'll ignore 0 values.
connect(cionConnection, &CionModbusRtuConnection::maxChargingCurrentE3Changed, thing, [=](quint16 maxChargingCurrentE3){
qCDebug(dcSchrack()) << "Maximum charging current E3 current changed:" << maxChargingCurrentE3;
qCInfo(dcSchrack()) << "Maximum charging current E3 current changed:" << maxChargingCurrentE3;
if (maxChargingCurrentE3 != 0) {
thing->setStateMaxValue(cionMaxChargingCurrentStateTypeId, maxChargingCurrentE3);
}
});
connect(cionConnection, &CionModbusRtuConnection::statusBitsChanged, thing, [=](quint16 /*statusBits*/){
connect(cionConnection, &CionModbusRtuConnection::statusBitsChanged, thing, [=](quint16 statusBits){
thing->setStateValue(cionConnectedStateTypeId, true);
// qCDebug(dcSchrack()) << "Status bits changed:" << statusBits;
StatusBits status = static_cast<StatusBits>(statusBits);
// TODO: Verify if the statusBit for PluggedIn is reliable and if so, use that instead of the plugged in time for the plugged in state.
qCInfo(dcSchrack()) << "Status bits changed:" << status;
});
connect(cionConnection, &CionModbusRtuConnection::minChargingCurrentChanged, thing, [=](quint16 minChargingCurrent){
qCDebug(dcSchrack()) << "Minimum charging current changed:" << minChargingCurrent;
qCInfo(dcSchrack()) << "Minimum charging current changed:" << minChargingCurrent;
if (minChargingCurrent > 32) {
// Apparently this register occationally holds random values... As a quick'n dirty workaround we'll ignore everything > 32
qCWarning(dcSchrack()) << "Detected a bogus min charging current register value (reg. 507) of" << minChargingCurrent << ". Ignoring it...";

View File

@ -50,6 +50,22 @@ class IntegrationPluginSchrack : public IntegrationPlugin
Q_INTERFACES(IntegrationPlugin)
public:
enum StatusBit {
StatusBitPluggedIn = 0x0001,
StatusBitChargeContactor1Active = 0x0002,
StatusBitChargeContactor2Active = 0x0004,
StatusBitVentilationRequired = 0x0008,
StatusBitPlugLockController = 0x0010,
StatusBitPlugLockReturn = 0x0020,
StatusBitCollectiveDisorder = 0x0040,
StatusBitDisorderFiLs = 0x0080,
StatusBitCableDisorder = 0x0100,
StatusBitCableRejected = 0x0200,
StatusBitContactorError = 0x0400
};
Q_ENUM(StatusBit);
Q_DECLARE_FLAGS(StatusBits, StatusBit)
explicit IntegrationPluginSchrack();
void init() override;
void discoverThings(ThingDiscoveryInfo *info) override;