diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx index e4fe4ed4c..3f5748a7b 100644 --- a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx @@ -168,7 +168,7 @@ function BatteryView(props: BatteryViewProps) { { + // return { BatteryId, battery }; // Here we return an object with the id and device + // }) + // .sort((a, b) => parseInt(b.BatteryId) - parseInt(a.BatteryId)) + // : []; + + const inverter = (props.values as any)?.InverterRecord; + const sortedBatteryView = - props.values != null && - props.values?.AcDcGrowatt?.BatteriesRecords?.Batteries - ? Object.entries(props.values.AcDcGrowatt.BatteriesRecords.Batteries) - .map(([BatteryId, battery]) => { - return { BatteryId, battery }; // Here we return an object with the id and device - }) - .sort((a, b) => parseInt(b.BatteryId) - parseInt(a.BatteryId)) + inverter + ? [ + { + BatteryId: '1', + battery: { + Voltage: inverter.Battery1Voltage, + Current: inverter.Battery1Current, + Power: inverter.Battery1Power, + Soc: inverter.Battery1Soc, + Soh: inverter.Battery1Soh, + // DailyDischargeEnergy: inverter.Battery1DailyDischargeEnergy, + // DailyChargeEnergy: inverter.Battery1DailyChargeEnergy, + } + }, + { + BatteryId: '2', + battery: { + Voltage: inverter.Battery2Voltage, + Current: inverter.Battery2Current, + Power: inverter.Battery2Power, + Soc: inverter.Battery2Soc, + Soh: inverter.Battery2Soh, + // DailyDischargeEnergy: inverter.Battery2DailyDischargeEnergy, + // DailyChargeEnergy: inverter.Battery2DailyChargeEnergy, + } + } + ]// filter out batteries where all numeric values are 0 or null/undefined + .filter(({ battery }) => + Object.values(battery).some( + (v) => typeof v === 'number' && v !== 0 + ) + ) : []; const [loading, setLoading] = useState(sortedBatteryView.length == 0); @@ -157,7 +194,7 @@ function BatteryViewSodioHome(props: BatteryViewSodioHomeProps) { {/**/} {/* */} {/* Current SoC SoH - Daily Charge Energy - Daily Discharge Energy + {/*Daily Charge Energy*/} + {/*Daily Discharge Energy*/} @@ -298,26 +335,26 @@ function BatteryViewSodioHome(props: BatteryViewSodioHomeProps) { > {battery.Soh + ' %'} - - {battery.DailyChargeEnergy + ' Wh'} - - - {battery.DailyDischargeEnergy + ' Wh'} - + {/**/} + {/* {battery.DailyChargeEnergy + ' Wh'}*/} + {/**/} + {/**/} + {/* {battery.DailyDischargeEnergy + ' Wh'}*/} + {/**/} ))} diff --git a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx index d8a79d74f..205413cdc 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx @@ -416,7 +416,7 @@ function Installation(props: singleInstallationProps) { /> } diff --git a/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx b/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx index 0ea92d9ba..a2b2898be 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Installations/InstallationSearch.tsx @@ -18,7 +18,7 @@ function InstallationSearch(props: installationSearchProps) { return ( } /> diff --git a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/InstallationSearch.tsx b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/InstallationSearch.tsx index 9f78d2235..1b3601874 100644 --- a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/InstallationSearch.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/InstallationSearch.tsx @@ -83,7 +83,7 @@ function InstallationSearch(props: installationSearchProps) { return ( 100 - ) { - SetErrorForField(name, true); + // case 'minimumSoC': + // if ( + // /[^0-9.]/.test(value) || + // isNaN(parseFloat(value)) || + // parseFloat(value) > 30 || + // parseFloat(value) < 10 + // ) { + // SetErrorForField(name, true); + // } else { + // SetErrorForField(name, false); + // } + // break; + case 'minimumSoC': { + const numValue = parseFloat(value); + + // Check for invalid characters or non-numeric + if (/[^0-9.]/.test(value) || isNaN(numValue)) { + SetErrorForField(name, { + hasError: true, + message: 'Invalid number format', + }); + break; + } + + // Define device-based ranges + const minsocRanges = { + 3: { min: 10, max: 30 }, + 4: { min: 5, max: 100 }, + }; + + // Fallback range if device not listed + const { min, max } = minsocRanges[device] || { min: 10, max: 30 }; + + if (numValue < min || numValue > max) { + SetErrorForField(name, { + hasError: true, + message: `Value should be between ${min}-${max}%`, + }); } else { - SetErrorForField(name, false); + SetErrorForField(name, { hasError: false, message: '' }); } break; + } + case 'gridSetPoint': if (/[^0-9.]/.test(value) || isNaN(parseFloat(value))) { SetErrorForField(name, true); @@ -238,7 +284,7 @@ function SodistoreHomeConfiguration(props: SodistoreHomeConfigurationProps) { helperText={ errors.minimumSoC ? ( - Value should be between 0-100% + Value should be between {device === 4 ? '5–100' : '10–30'}% ) : ( '' diff --git a/typescript/frontend-marios2/src/content/dashboards/Tree/InstallationTree.tsx b/typescript/frontend-marios2/src/content/dashboards/Tree/InstallationTree.tsx index 2c47e639a..64f91ad68 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tree/InstallationTree.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tree/InstallationTree.tsx @@ -78,7 +78,7 @@ function InstallationTree() { return (