Skip to content

Commit

Permalink
fix: improve dynamic colour of load icon when three_phase = true and …
Browse files Browse the repository at this point in the history
…aux_power > 0
  • Loading branch information
slipx06 committed Feb 20, 2024
1 parent bd62fdf commit b48782f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/sunsynk-power-flow-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sunsynk-power-flow-card",
"version": "4.16.0",
"version": "4.16.1",
"description": "A customizable Home Assistant card to emulate the Sunsynk System flow that's displayed on the Inverter screen.",
"main": "sunsynk-power-flow-card.js",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class SunsynkPowerFlowCard extends LitElement {

//Load
const state_essential_power = this.getEntity('essential_power');
const state_aux_power = this.getEntity('aux_power_166');
const state_aux_power = this.getEntity('aux_power_166', {state: '0'});
const state_nonessential_power = this.getEntity('nonessential_power');
const state_non_essential_load1 = this.getEntity('non_essential_load1');
const state_non_essential_load2 = this.getEntity('non_essential_load2');
Expand Down Expand Up @@ -908,10 +908,10 @@ export class SunsynkPowerFlowCard extends LitElement {
? 0
: priority === 'off' || !priority
? battery_power > 0
? (total_pv / essential) * 100
: ((total_pv - Math.abs(battery_power)) / essential) * 100
: (total_pv / essential) * 100;
const batteryPercentage_raw = battery_power <= 0 ? 0 : (Math.abs(battery_power) / essential) * 100;
? (total_pv / (three_phase ? essential + Math.max(aux_power, 0) : essential)) * 100
: ((total_pv - Math.abs(battery_power)) / (three_phase ? essential + Math.max(aux_power, 0) : essential)) * 100
: (total_pv / (three_phase ? essential + Math.max(aux_power, 0) : essential)) * 100;
const batteryPercentage_raw = battery_power <= 0 ? 0 : (Math.abs(battery_power) / (three_phase ? essential + Math.max(aux_power, 0) : essential)) * 100;

// Normalize percentages
const totalPercentage = pvPercentage_raw + batteryPercentage_raw;
Expand Down

0 comments on commit b48782f

Please sign in to comment.