Sungrow: Fix battery calculations for inverter firmware since 2024
parent
8f47c12b23
commit
6e1101ec06
|
|
@ -214,7 +214,7 @@ void IntegrationPluginSungrow::setupThing(ThingSetupInfo *info)
|
|||
// Update the meter if available
|
||||
Thing *meterThing = getMeterThing(thing);
|
||||
if (meterThing) {
|
||||
auto runningState = sungrowConnection->runningState();
|
||||
quint16 runningState = sungrowConnection->runningState();
|
||||
qCDebug(dcSungrow()) << "Power generated from PV:" << (runningState & (0x1 << 0) ? "true" : "false");
|
||||
qCDebug(dcSungrow()) << "Battery charging:" << (runningState & (0x1 << 1) ? "true" : "false");
|
||||
qCDebug(dcSungrow()) << "Battery discharging:" << (runningState & (0x1 << 2) ? "true" : "false");
|
||||
|
|
@ -245,7 +245,14 @@ void IntegrationPluginSungrow::setupThing(ThingSetupInfo *info)
|
|||
batteryThing->setStateValue(sungrowBatteryBatteryLevelStateTypeId, sungrowConnection->batteryLevel());
|
||||
batteryThing->setStateValue(sungrowBatteryBatteryCriticalStateTypeId, sungrowConnection->batteryLevel() < 5);
|
||||
|
||||
batteryThing->setStateValue(sungrowBatteryCurrentPowerStateTypeId, sungrowConnection->batteryPower());
|
||||
// Note: since firmware 2024 this is a int16 value, and we can use the value directly without convertion
|
||||
if (sungrowConnection->batteryPower() < 0) {
|
||||
batteryThing->setStateValue(sungrowBatteryCurrentPowerStateTypeId, sungrowConnection->batteryPower());
|
||||
} else {
|
||||
qint16 batteryPower = (sungrowConnection->runningState() & (0x1 << 1) ? sungrowConnection->batteryPower() : sungrowConnection->batteryPower() * -1);
|
||||
batteryThing->setStateValue(sungrowBatteryCurrentPowerStateTypeId, batteryPower);
|
||||
}
|
||||
|
||||
quint16 runningState = sungrowConnection->runningState();
|
||||
if (runningState & (0x1 << 1)) { //Bit 1: Battery charging bit
|
||||
batteryThing->setStateValue(sungrowBatteryChargingStateStateTypeId, "charging");
|
||||
|
|
|
|||
|
|
@ -310,7 +310,109 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"id": "energyValues2",
|
||||
"id": "energyValues3",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
"id": "meterVoltagePhaseA",
|
||||
"address": 5740,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter voltage phase A",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -1,
|
||||
"unit": "Volt",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterVoltagePhaseB",
|
||||
"address": 5741,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter voltage phase B",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -1,
|
||||
"unit": "Volt",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterVoltagePhaseC",
|
||||
"address": 5742,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter voltage phase C",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -1,
|
||||
"unit": "Volt",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterCurrentPhaseA",
|
||||
"address": 5743,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter current phase A",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -2,
|
||||
"unit": "Amper",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterCurrentPhaseB",
|
||||
"address": 5744,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter current phase B",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -2,
|
||||
"unit": "Amper",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterCurrentPhaseC",
|
||||
"address": 5745,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter current phase C",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -2,
|
||||
"unit": "Amper",
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterTotalEnergyImported",
|
||||
"address": 5746,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter totoal energy imported",
|
||||
"unit": "kWh",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -2,
|
||||
"access": "RO"
|
||||
},
|
||||
{
|
||||
"id": "meterTotalEnergyExported",
|
||||
"address": 5748,
|
||||
"size": 2,
|
||||
"type": "uint32",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Meter totoal energy exported",
|
||||
"unit": "kWh",
|
||||
"defaultValue": "0",
|
||||
"staticScaleFactor": -2,
|
||||
"access": "RO"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "energyValues4",
|
||||
"readSchedule": "update",
|
||||
"registers": [
|
||||
{
|
||||
|
|
@ -465,7 +567,7 @@
|
|||
"id": "batteryPower",
|
||||
"address": 13021,
|
||||
"size": 1,
|
||||
"type": "uint16",
|
||||
"type": "int16",
|
||||
"registerType": "inputRegister",
|
||||
"description": "Battery power",
|
||||
"unit": "W",
|
||||
|
|
|
|||
Loading…
Reference in New Issue