adapt data path for growatt and sinexcel

This commit is contained in:
Yinyin Liu 2026-04-15 15:28:24 +02:00
parent 45a3c62609
commit 544f9602e1
3 changed files with 22 additions and 17 deletions

View File

@ -1140,7 +1140,11 @@ export const getHighestConnectionValue = (values: JSONRecordData) => {
'InverterRecord.PvPower',
'InverterRecord.Battery1Power',
'InverterRecord.Battery2Power',
'InverterRecord.ConsumptionPower'
'InverterRecord.ConsumptionPower',
'InverterRecord.TotalBatteryPower',
'InverterRecord.TotalPhotovoltaicPower',
'InverterRecord.TotalLoadPower',
'InverterRecord.TotalGridPower'
];
// Helper function to safely get a value from a nested path

View File

@ -91,8 +91,8 @@ function SodistoreHomeConfiguration(props: SodistoreHomeConfigurationProps) {
// Helper to build form values from S3 data
const getS3Values = (): Partial<ConfigurationValues> => ({
minimumSoC: props.values.Config.MinSoc,
maximumDischargingCurrent: props.values.Config.MaximumChargingCurrent,
maximumChargingCurrent: props.values.Config.MaximumDischargingCurrent,
maximumDischargingCurrent: props.values.Config.MaximumDischargingCurrent,
maximumChargingCurrent: props.values.Config.MaximumChargingCurrent,
operatingPriority: resolveOperatingPriorityIndex(
props.values.Config.OperatingPriority
),

View File

@ -42,21 +42,21 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
const inv = props.values?.InverterRecord;
const hasDevices = !!inv?.Devices;
const growattActiveIndices: number[] = hasDevices
? []
: Array.from({ length: props.batteryClusterNumber }, (_, i) => i + 1)
.filter((i) => Number(inv?.[`Battery${i}Voltage`]) > 0);
const totalBatteryPower: number = hasDevices
? (inv?.TotalBatteryPower ?? 0)
: Number(
Array.from({ length: props.batteryClusterNumber }).reduce(
(sum: number, _, index) => sum + (Number(inv?.[`Battery${index + 1}Power`]) || 0),
0
)
: growattActiveIndices.reduce(
(sum, i) => sum + (Number(inv?.[`Battery${i}Power`]) || 0),
0
);
const pvPower: number = hasDevices
? (inv?.TotalPhotovoltaicPower ?? 0)
: (inv?.PvPower ??
['PvPower1', 'PvPower2', 'PvPower3', 'PvPower4']
.map((key) => inv?.[key] ?? 0)
.reduce((sum, val) => sum + val, 0));
: (inv?.PvPower ?? 0);
const totalLoadPower: number = hasDevices
? (inv?.TotalLoadPower ?? 0)
@ -67,11 +67,12 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
const avgBatterySoc: number = hasDevices
? (inv?.AvgBatterySoc ?? 0)
: (() => {
const socs = Array.from({ length: props.batteryClusterNumber })
.map((_, i) => Number(inv?.[`Battery${i + 1}Soc`]) || 0);
return socs.length ? socs.reduce((s, v) => s + v, 0) / socs.length : 0;
})();
: (growattActiveIndices.length
? growattActiveIndices.reduce(
(sum, i) => sum + (Number(inv?.[`Battery${i}Soc`]) || 0),
0
) / growattActiveIndices.length
: 0);
return (
<Container maxWidth="xl" style={{ backgroundColor: 'white' }}>