Fix a bug in energy batteryToGrid calculation (#19958)

This commit is contained in:
karwosts 2024-03-04 09:44:17 -05:00 committed by GitHub
parent 50da4bcd37
commit 5523cd6203
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 6 deletions

View File

@ -177,7 +177,7 @@ class HuiEnergyDistrubutionCard
if (hasBattery) {
batteryFromGrid = solarConsumption * -1;
if (batteryFromGrid > totalFromGrid) {
batteryToGrid = Math.min(0, batteryFromGrid - totalFromGrid);
batteryToGrid = batteryFromGrid - totalFromGrid;
batteryFromGrid = totalFromGrid;
}
}

View File

@ -150,7 +150,7 @@ class HuiEnergySelfSufficiencyGaugeCard
if (hasBattery) {
batteryFromGrid = solarConsumption * -1;
if (batteryFromGrid > totalFromGrid) {
batteryToGrid = Math.min(0, batteryFromGrid - totalFromGrid);
batteryToGrid = batteryFromGrid - totalFromGrid;
batteryFromGrid = totalFromGrid;
}
}

View File

@ -434,10 +434,8 @@ export class HuiEnergyUsageGraphCard
if (summedData.to_battery) {
grid_to_battery[start] = used_solar[start] * -1;
if (grid_to_battery[start] > (summedData.from_grid?.[start] || 0)) {
battery_to_grid[start] = Math.min(
0,
grid_to_battery[start] - (summedData.from_grid?.[start] || 0)
);
battery_to_grid[start] =
grid_to_battery[start] - (summedData.from_grid?.[start] || 0);
grid_to_battery[start] = summedData.from_grid?.[start];
}
}