fixed some potential segfaults
parent
8367e868ea
commit
59510f23ea
|
|
@ -356,11 +356,15 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
thing->setStateValue(liveWallboxCurrentPhase3StateTypeId, data[0]);
|
thing->setStateValue(liveWallboxCurrentPhase3StateTypeId, data[0]);
|
||||||
break;
|
break;
|
||||||
case Webasto::TqActivePower: {
|
case Webasto::TqActivePower: {
|
||||||
|
if (data.count() < 2)
|
||||||
|
return;
|
||||||
int power = (static_cast<quint32>(data[0])<<16 | data[1]);
|
int power = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
qCDebug(dcWebasto()) << " - Active power:" << power;
|
qCDebug(dcWebasto()) << " - Active power:" << power;
|
||||||
thing->setStateValue(liveWallboxPowerConsumptionStateTypeId, power);
|
thing->setStateValue(liveWallboxPowerConsumptionStateTypeId, power);
|
||||||
} break;
|
} break;
|
||||||
case Webasto::TqEnergyMeter: {
|
case Webasto::TqEnergyMeter: {
|
||||||
|
if (data.count() < 2)
|
||||||
|
return;
|
||||||
int energy = (static_cast<quint32>(data[0])<<16 | data[1]);
|
int energy = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
qCDebug(dcWebasto()) << " - Energy meter:" << energy << "Wh";
|
qCDebug(dcWebasto()) << " - Energy meter:" << energy << "Wh";
|
||||||
thing->setStateValue(liveWallboxTotalEnergyConsumedStateTypeId, energy);
|
thing->setStateValue(liveWallboxTotalEnergyConsumedStateTypeId, energy);
|
||||||
|
|
@ -387,15 +391,21 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
case Webasto::TqEVBatteryState:
|
case Webasto::TqEVBatteryState:
|
||||||
qCDebug(dcWebasto()) << " - Battery state" << data[0];
|
qCDebug(dcWebasto()) << " - Battery state" << data[0];
|
||||||
break;
|
break;
|
||||||
case Webasto::TqEVBatteryCapacity:
|
case Webasto::TqEVBatteryCapacity: {
|
||||||
qCDebug(dcWebasto()) << " - Battery capacity" << data[0];
|
if (data.count() < 2)
|
||||||
break;
|
return;
|
||||||
|
uint batteryCapacity = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
|
qCDebug(dcWebasto()) << " - Battery capacity" << batteryCapacity << "Wh";
|
||||||
|
} break;
|
||||||
case Webasto::TqScheduleType:
|
case Webasto::TqScheduleType:
|
||||||
qCDebug(dcWebasto()) << " - Schedule type" << data[0];
|
qCDebug(dcWebasto()) << " - Schedule type" << data[0];
|
||||||
break;
|
break;
|
||||||
case Webasto::TqRequiredEnergy:
|
case Webasto::TqRequiredEnergy: {
|
||||||
qCDebug(dcWebasto()) << " - Required energy" << data[0];
|
if (data.count() < 2)
|
||||||
break;
|
return;
|
||||||
|
uint requiredEnergy = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
|
qCDebug(dcWebasto()) << " - Required energy" << requiredEnergy;
|
||||||
|
} break;
|
||||||
case Webasto::TqRequiredBatteryState:
|
case Webasto::TqRequiredBatteryState:
|
||||||
qCDebug(dcWebasto()) << " - Required battery state" << data[0];
|
qCDebug(dcWebasto()) << " - Required battery state" << data[0];
|
||||||
break;
|
break;
|
||||||
|
|
@ -410,16 +420,26 @@ void IntegrationPluginWebasto::onReceivedRegister(Webasto::TqModbusRegister modb
|
||||||
thing->setStateValue(liveWallboxSessionEnergyStateTypeId, data[0]/1000.00); // Charged energy in kWh
|
thing->setStateValue(liveWallboxSessionEnergyStateTypeId, data[0]/1000.00); // Charged energy in kWh
|
||||||
break;
|
break;
|
||||||
case Webasto::TqStartTime:
|
case Webasto::TqStartTime:
|
||||||
qCDebug(dcWebasto()) << " - Start time" << data[0];
|
qCDebug(dcWebasto()) << " - Start time" << (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
break;
|
|
||||||
case Webasto::TqChargingTime:
|
|
||||||
qCDebug(dcWebasto()) << " - Charging time" << data[0];
|
|
||||||
thing->setStateValue(liveWallboxSessionTimeStateTypeId, data[0]/60.00); // Charging time in minutes
|
|
||||||
break;
|
|
||||||
case Webasto::TqEndTime:
|
|
||||||
qCDebug(dcWebasto()) << " - End time" << data[0];
|
|
||||||
break;
|
break;
|
||||||
|
case Webasto::TqChargingTime: {
|
||||||
|
if (data.count() < 2)
|
||||||
|
return;
|
||||||
|
uint seconds = (static_cast<quint32>(data[0])<<16 | data[1]);
|
||||||
|
qCDebug(dcWebasto()) << " - Charging time" << seconds << "s";
|
||||||
|
thing->setStateValue(liveWallboxSessionTimeStateTypeId, seconds/60.00); // Charging time in minutes
|
||||||
|
} break;
|
||||||
|
case Webasto::TqEndTime: {
|
||||||
|
if (data.count() < 2)
|
||||||
|
return;
|
||||||
|
uint hour = ((static_cast<quint32>(data[0])<<16 | data[1])&0xff0000)>>16;
|
||||||
|
uint minutes = ((static_cast<quint32>(data[0])<<16 | data[1])&0x00ff00)>>8;
|
||||||
|
uint seconds= (static_cast<quint32>(data[0])<<16 | data[1])&0x0000ff;
|
||||||
|
qCDebug(dcWebasto()) << " - End time" << hour << "h" << minutes << "m" << seconds << "s";
|
||||||
|
} break;
|
||||||
case Webasto::TqUserId: {
|
case Webasto::TqUserId: {
|
||||||
|
if (data.count() < 10)
|
||||||
|
return;
|
||||||
QByteArray userID;
|
QByteArray userID;
|
||||||
Q_FOREACH(quint16 i, data) {
|
Q_FOREACH(quint16 i, data) {
|
||||||
userID.append(i>>16);
|
userID.append(i>>16);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue