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.PvPower',
'InverterRecord.Battery1Power', 'InverterRecord.Battery1Power',
'InverterRecord.Battery2Power', '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 // 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 // Helper to build form values from S3 data
const getS3Values = (): Partial<ConfigurationValues> => ({ const getS3Values = (): Partial<ConfigurationValues> => ({
minimumSoC: props.values.Config.MinSoc, minimumSoC: props.values.Config.MinSoc,
maximumDischargingCurrent: props.values.Config.MaximumChargingCurrent, maximumDischargingCurrent: props.values.Config.MaximumDischargingCurrent,
maximumChargingCurrent: props.values.Config.MaximumDischargingCurrent, maximumChargingCurrent: props.values.Config.MaximumChargingCurrent,
operatingPriority: resolveOperatingPriorityIndex( operatingPriority: resolveOperatingPriorityIndex(
props.values.Config.OperatingPriority props.values.Config.OperatingPriority
), ),

View File

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