Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
flixlix committed Oct 13, 2024
2 parents 88d7669 + 67b0224 commit 41336b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/energy-flow-card-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,14 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
}
solar.state.toBattery = battery.state.toBattery! - (grid.state.toBattery || 0);
} else if (!solar.has && battery.has) {
// In the absence of solar production, the battery is the only energy producer
// besides the grid, so whatever was given to the grid must come from
// the battery
battery.state.toGrid = grid.state.toGrid ?? 0;

// In the absence of solar production, what was consumed by the battery
// must come from the grid, since there are no other energy producers.
grid.state.toBattery = (battery.state.toBattery ?? 0);
}

// Update State Values of Solar to Grid
Expand Down Expand Up @@ -855,7 +862,7 @@ export default class EnergyFlowCardPlus extends SubscribeMixin(LitElement) {
const totalIndividualConsumption = coerceNumber(individual1.state, 0) + coerceNumber(individual2.state, 0);

// Calculate Sum of All Sources to get Total Home Consumption
const totalHomeConsumption = Math.max(grid.state.fromGrid + (solar.state.toHome ?? 0) + (battery.state.toHome ?? 0), 0);
const totalHomeConsumption = Math.max(grid.state.fromGrid - (grid.state.toBattery ?? 0) + (solar.state.toHome ?? 0) + (battery.state.toHome ?? 0), 0);

// Calculate Circumference of Semi-Circles
let homeBatteryCircumference = 0;
Expand Down

0 comments on commit 41336b3

Please sign in to comment.