Skip to content

Commit

Permalink
Merge pull request #353 from flixlix/348-bug-points-moving-despite-w-…
Browse files Browse the repository at this point in the history
…being-displayed-as-0

fix: 🐛 lines displayed when displayed value 0
  • Loading branch information
flixlix authored Aug 12, 2023
2 parents 25f6708 + a5dc5f0 commit 1a77b24
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/power-flow-card-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ export class PowerFlowCardPlus extends LitElement {

if (solar.has) {
solar.state.toHome = (solar.state.total ?? 0) - (grid.state.toGrid ?? 0) - (battery.state.toBattery ?? 0);
if (entities.solar?.display_zero_tolerance) {
if (entities.solar.display_zero_tolerance >= (solar.state.total || 0) ) solar.state.toHome = 0;
}
}
const largestGridBatteryTolerance = Math.max(entities.grid?.display_zero_tolerance ?? 0, entities.battery?.display_zero_tolerance ?? 0);

Expand Down Expand Up @@ -576,6 +579,9 @@ export class PowerFlowCardPlus extends LitElement {
);
}
solar.state.toBattery = battery.state.toBattery - (grid.state.toBattery || 0);
if (entities.solar?.display_zero_tolerance) {
if (entities.solar.display_zero_tolerance >= (solar.state.total || 0) ) solar.state.toBattery = 0;
}
} else {
battery.state.toGrid = grid.state.toGrid || 0;
}
Expand All @@ -586,6 +592,9 @@ export class PowerFlowCardPlus extends LitElement {
grid.state.toHome = Math.max(grid.state.fromGrid - (grid.state.toBattery ?? 0), 0);

if (solar.has && grid.state.toGrid) solar.state.toGrid = grid.state.toGrid - (battery.state.toGrid ?? 0);
if (entities.solar?.display_zero_tolerance) {
if (entities.solar.display_zero_tolerance >= (solar.state.total || 0) ) solar.state.toGrid = 0;
}
this.style.setProperty("--text-solar-color", entities.solar?.color_value ? "var(--energy-solar-color)" : "var(--primary-text-color)");

if (grid.color.fromGrid !== undefined) {
Expand Down Expand Up @@ -623,7 +632,11 @@ export class PowerFlowCardPlus extends LitElement {
if (entities.grid?.display_zero_tolerance !== undefined) {
solar.state.toGrid = (solar.state.toGrid ?? 0) > entities.grid?.display_zero_tolerance ? solar.state.toGrid : 0;
grid.state.toGrid = (grid.state.toGrid ?? 0) > entities.grid?.display_zero_tolerance ? grid.state.toGrid : 0;
grid.state.fromGrid = grid.state.fromGrid! > entities.grid?.display_zero_tolerance ? grid.state.fromGrid : 0;
if(grid.state.fromGrid <= entities.grid?.display_zero_tolerance) {
grid.state.fromGrid = 0;
grid.state.toHome = 0;
grid.state.toBattery = 0;
}
}

this.style.setProperty(
Expand Down

0 comments on commit 1a77b24

Please sign in to comment.