From 334ee4e6c17963ea69e10647fea926bb1dfcf509 Mon Sep 17 00:00:00 2001 From: atef Date: Mon, 20 Oct 2025 15:01:18 +0200 Subject: [PATCH] Add the GRid Power, Exported and imported power --- .../WITGrowatt4-15K/WITGrowatRecord.Api.cs | 30 ++++++++++++++----- .../WITGrowatt4-15K/WITGrowatRecord.Modbus.cs | 23 +++++++++----- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Api.cs b/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Api.cs index 9acb4d78e..748ca514a 100644 --- a/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Api.cs +++ b/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Api.cs @@ -13,6 +13,9 @@ public partial class WITGrowatRecord { // private List Batteries { get; set; } = new(); //public BatteriesRecord? BatteriesRecords => BatteriesRecord.FromBatteries(Batteries); + + + public ActivePower ConsumptionPower => MeterPower + InverterActivePower ; public ActivePower InverterActivePower => _ActivePower; public ReactivePower InverterReactivePower => _ReactivePower; public Frequency Frequency => _Frequency; @@ -24,13 +27,9 @@ public partial class WITGrowatRecord public CurrentRms PhaseBCurrent => _PhaseBCurrent; public CurrentRms PhaseCCurrent => _PhaseCCurrent; - public Int32 MeterPower => _MeterPower; - public ActivePower GridMeterPower => _GridPower; - public Int32 BatteryPower1 - { - get => _BatteryPower1; - set => _BatteryPower1 = value; - } + public ActivePower MeterPower => _importedPowerFromGrid - _exportedPowerToGrid; + public ActivePower ExportedPowerToGridMeter => _exportedPowerToGrid; + public ActivePower ImportedPowerFromGrid => _importedPowerFromGrid; public Temperature InverterTemperature => _InverterTemperature; @@ -52,15 +51,30 @@ public partial class WITGrowatRecord public Current Pv1Current => _Pv1Current; public Voltage Pv2Voltage => _Pv2Voltage; public Current Pv2Current => _Pv2Current; + public Voltage Pv3Voltage => _Pv3Voltage; + public Current Pv3Current => _Pv3Current; + public Voltage Pv4Voltage => _Pv4Voltage; + public Current Pv4Current => _Pv4Current; + public Voltage Pv5Voltage => _Pv5Voltage; + public Current Pv5Current => _Pv5Current; + public Voltage Pv6Voltage => _Pv6Voltage; + public Current Pv6Current => _Pv6Current; + + public DcPower Pv1InpuPower => _Pv1InpuPower; + + + public DcPower TotalPvPower => (Pv1Voltage * Pv1Current) + (Pv2Voltage * Pv2Current) + + (Pv3Voltage * Pv3Current) + (Pv4Voltage * Pv4Current) + + (Pv5Voltage * Pv5Current) + (Pv6Voltage * Pv6Current); // ********************************** Holding Registers (Control) ************************************************************* // public UInt16 DeviceModel => _DeviceModel; public UInt32 RatedPower { - get => _RatedPower; + get => _ratedPower; } public UInt32 MaxActivePower diff --git a/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Modbus.cs b/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Modbus.cs index 2306ee682..a1e19f588 100644 --- a/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Modbus.cs +++ b/csharp/Lib/Devices/WITGrowatt4-15K/WITGrowatRecord.Modbus.cs @@ -10,8 +10,9 @@ public partial class WITGrowatRecord { /****************************** Input registers ****************************/ - [InputRegister(35, Scale = 0.1)] private Int32 _GridPower; - + [InputRegister(8081, Scale = 0.1)] private Int32 _importedPowerFromGrid; + [InputRegister(8083, Scale = 0.1)] private Int32 _exportedPowerToGrid; + // 31000–31009 — Operating Status Info [InputRegister(31000)] private UInt16 _SystemOperatingMode; [InputRegister(31001)] private UInt16 _BatteryOperatingMode; @@ -24,10 +25,18 @@ public partial class WITGrowatRecord [InputRegister(31008)] private UInt16 _WarningSubCode; [InputRegister(31009)] private UInt16 _Reserved3; // 31010–31099 — PV Parameters - [InputRegister(31010)] private Int16 _Pv1Voltage; - [InputRegister(31011)] private Int16 _Pv1Current; - [InputRegister(31012)] private Int16 _Pv2Voltage; - [InputRegister(31013)] private Int16 _Pv2Current; + [InputRegister(31010,Scale = 0.1)] private Int16 _Pv1Voltage; + [InputRegister(31011,Scale = 0.1)] private Int16 _Pv1Current; + [InputRegister(31012,Scale = 0.1)] private Int16 _Pv2Voltage; + [InputRegister(31013,Scale = 0.1)] private Int16 _Pv2Current; + [InputRegister(31014,Scale = 0.1)] private Int16 _Pv3Voltage; + [InputRegister(31015,Scale = 0.1)] private Int16 _Pv3Current; + [InputRegister(31016,Scale = 0.1)] private Int16 _Pv4Voltage; + [InputRegister(31017,Scale = 0.1)] private Int16 _Pv4Current; + [InputRegister(31018,Scale = 0.1)] private Int16 _Pv5Voltage; + [InputRegister(31019,Scale = 0.1)] private Int16 _Pv5Current; + [InputRegister(31020,Scale = 0.1)] private Int16 _Pv6Voltage; + [InputRegister(31021,Scale = 0.1)] private Int16 _Pv6Current; [InputRegister(31058)] private Int16 _Pv1InpuPower; //— AC Side 31100 - 31199 @@ -129,7 +138,7 @@ public partial class WITGrowatRecord /****************************** Holding registers ****************************/ // [HoldingRegister(30000)] private UInt16 _DeviceModel; - [HoldingRegister(30016, Scale = 0.1)] private UInt32 _RatedPower; + [HoldingRegister(30016, Scale = 0.1)] private UInt32 _ratedPower; [HoldingRegister(30018, Scale = 0.1)] private UInt32 _MaxActivePower; [HoldingRegister(30028, Scale = 0.1)] private UInt32 _PvInputMaxPower; [HoldingRegister(30030)] private UInt16 _BatteryType;