fix main stats of sinexcel battery view
This commit is contained in:
parent
68d057b919
commit
cc1ec216ee
|
|
@ -233,20 +233,45 @@ export const transformInputToBatteryViewDataJson = async (
|
|||
});
|
||||
}
|
||||
|
||||
// Map category names to InverterRecord field suffixes
|
||||
const categoryFieldMap = {
|
||||
const hasDevices = !!inv?.Devices;
|
||||
|
||||
// Sinexcel field suffixes differ from Growatt for Voltage/Current
|
||||
const categoryFieldMapGrowatt = {
|
||||
Soc: 'Soc',
|
||||
Power: 'Power',
|
||||
Voltage: 'Voltage',
|
||||
Current: 'Current',
|
||||
Soh: 'Soh'
|
||||
};
|
||||
const categoryFieldMapSinexcel = {
|
||||
Soc: 'Soc',
|
||||
Power: 'Power',
|
||||
Voltage: 'PackTotalVoltage',
|
||||
Current: 'PackTotalCurrent',
|
||||
Soh: 'Soh'
|
||||
};
|
||||
|
||||
for (let j = 0; j < pathsToSave.length; j++) {
|
||||
const batteryIndex = j + 1; // Battery1, Battery2, ...
|
||||
categories.forEach((category) => {
|
||||
const fieldName = `Battery${batteryIndex}${categoryFieldMap[category]}`;
|
||||
const value = inv[fieldName];
|
||||
let value: number | undefined;
|
||||
|
||||
if (hasDevices) {
|
||||
// Sinexcel: nested under Devices — 0→D1/B1, 1→D1/B2, 2→D2/B1, ...
|
||||
const deviceId = String(Math.floor(j / 2) + 1);
|
||||
const bi = (j % 2) + 1;
|
||||
const device = inv.Devices[deviceId];
|
||||
const fieldName = `Battery${bi}${categoryFieldMapSinexcel[category]}`;
|
||||
value = device?.[fieldName];
|
||||
// Fallback for Soc
|
||||
if ((value === undefined || value === null) && category === 'Soc') {
|
||||
value = device?.[`Battery${bi}SocSecondvalue`];
|
||||
}
|
||||
} else {
|
||||
// Growatt: flat Battery1Soc, Battery2Voltage, ...
|
||||
const batteryIndex = j + 1;
|
||||
const fieldName = `Battery${batteryIndex}${categoryFieldMapGrowatt[category]}`;
|
||||
value = inv[fieldName];
|
||||
}
|
||||
|
||||
if (value !== undefined && value !== null) {
|
||||
if (value < chartOverview[category].min) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue