mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-07 18:56:34 +00:00
Fix typo in energy calculation (#25259)
* New energy calculation * more tests and stricter tests. change priority order * more test and fix error
This commit is contained in:
parent
2b06742bb9
commit
f24b6a4cb1
@ -1062,7 +1062,7 @@ export const computeConsumptionSingle = (data: {
|
||||
// Grid_In -> Battery_In
|
||||
grid_to_battery = Math.min(from_grid, to_battery);
|
||||
from_grid -= grid_to_battery;
|
||||
to_battery -= to_battery;
|
||||
to_battery -= grid_to_battery;
|
||||
|
||||
// Solar -> Consumption
|
||||
used_solar = Math.min(used_total_remaining, solar);
|
||||
|
@ -462,6 +462,8 @@ describe("Energy Usage Calculation Tests", () => {
|
||||
used_total: 9,
|
||||
}
|
||||
);
|
||||
});
|
||||
it("Solar -> Battery -> Grid", () => {
|
||||
assert.deepEqual(
|
||||
checkConsumptionResult({
|
||||
from_grid: 0,
|
||||
@ -482,4 +484,25 @@ describe("Energy Usage Calculation Tests", () => {
|
||||
}
|
||||
);
|
||||
});
|
||||
it("Solar -> Grid && Grid -> Battery", () => {
|
||||
assert.deepEqual(
|
||||
checkConsumptionResult({
|
||||
from_grid: 1,
|
||||
to_grid: 1,
|
||||
solar: 1,
|
||||
to_battery: 1,
|
||||
from_battery: 0,
|
||||
}),
|
||||
{
|
||||
grid_to_battery: 1,
|
||||
battery_to_grid: 0,
|
||||
used_solar: 0,
|
||||
used_grid: 0,
|
||||
used_battery: 0,
|
||||
solar_to_battery: 0,
|
||||
solar_to_grid: 1,
|
||||
used_total: 0,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user