Skip to content

Commit

Permalink
feat: add solar efficiency option
Browse files Browse the repository at this point in the history
  • Loading branch information
slipx06 committed Apr 28, 2024
1 parent fdea602 commit 7d80a50
Show file tree
Hide file tree
Showing 23 changed files with 299 additions and 80 deletions.
18 changes: 9 additions & 9 deletions dist/sunsynk-power-flow-card.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ These attributes are only needed if `show_solar` is set to `true`
| mppts: | **Required** | `2` | Specify the number of MPPT's in use `1`, `2`, `3` or `4`
| animation_speed: | Optional | `9` | Set slowest animation speed in seconds, depending on Power produced
| max_power: | Optional | `8000` | Maximum power draw to calculate animation speed
| pv1_name: | Optional | `PV1` | Set the disaply name for MPPT1
| pv2_name: | Optional | `PV2` | Set the disaply name for MPPT2
| pv3_name: | Optional | `PV3` | Set the disaply name for MPPT3
| pv1_name: | Optional | `PV1` | Set the disaply name for MPPT1
| pv1_max_power: | Optional | | Maximum power of MPPT1 based on the number and size of panels. Used to calculate solar efficiency of the string (W)
| pv2_name: | Optional | `PV2` | Set the disaply name for MPPT2
| pv2_max_power: | Optional | | Maximum power of MPPT2 based on the number and size of panels. Used to calculate solar efficiency of the string (W)
| pv3_name: | Optional | `PV3` | Set the disaply name for MPPT3
| pv3_max_power: | Optional | | Maximum power of MPPT3 based on the number and size of panels. Used to calculate solar efficiency of the string (W)
| pv4_name: | Optional | `PV4` | Set the disaply name for MPPT4
| pv4_max_power: | Optional | | Maximum power of MPPT4 based on the number and size of panels. Used to calculate solar efficiency of the string (W)
| auto_scale: | Optional | `true` | If set to `true` the card will use the entities `unit_of_measurement` attribute to perform the correct scaling (i,e, power values greater than 999W will be displayed as kW e.g. 1.23kW) and display the correct unit. The number of decimal places can be changed using the `decimal_places` card attribute apart from the daily energy values which are set using the `decimal_places_energy` attribute
| efficiency: | Optional | `0` | `0` - Disabled, `1` - Graphic display, `2` - Text display, `3` - Graphic and text display.

### Load

Expand Down
5 changes: 5 additions & 0 deletions docs/examples/sunsynk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,17 @@ Full Configuration (All Options)
animation_speed: 9
max_power: 8000
pv1_name: North
pv1_max_power: 2750
pv2_name: North
pv2_max_power: 2750
pv3_name: East
pv3_max_power: 2750
pv4_name: West
pv4_max_power: 2750
auto_scale: true
display_mode: 1
dynamic_colour: true
efficiency: 3
load:
colour: '#5fb6ad'
show_daily: true
Expand Down
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.33.0",
"version": "4.34.0",
"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
135 changes: 115 additions & 20 deletions src/cards/compact-card.ts

Large diffs are not rendered by default.

141 changes: 118 additions & 23 deletions src/cards/full-card.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default {
auto_scale: true,
display_mode: 1,
dynamic_colour: true,
efficiency: 0,
},
load: {
colour: '#5fb6ad',
Expand Down
1 change: 1 addition & 0 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export class SunSynkCardEditor extends ScopedRegistryHost(LitElement) implements
{name: 'dynamic_colour', selector: {boolean: {}}},
{name: 'animation_speed', selector: {number: {}}},
{name: 'max_power', selector: {number: {}}},
{name: 'efficiency', selector: {number: {mode: 'box', min: 0, max: 3,}}},
]
}]
}, {
Expand Down
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ export class SunsynkPowerFlowCard extends LitElement {
nonessentialLoads = 0;
}

let pvEfficiencyMode = config.solar?.efficiency;
if (!validnonLoadValues.includes(pvEfficiencyMode)) {
pvEfficiencyMode = 0;
}

let gridShowDailyBuy = config.grid?.show_daily_buy;
let gridShowDailySell = config.grid?.show_daily_sell;

Expand Down Expand Up @@ -913,6 +918,12 @@ export class SunsynkPowerFlowCard extends LitElement {

const {batteryIcon, batteryCharge, stopColour, battery0} = BatteryIconManager.convert(stateBatterySoc)

//Calculate pv efficiency
const totalPVEfficiency = (!config.solar.max_power || config.solar.efficiency === 0) ? 100 : Utils.toNum(Math.min((totalPV / config.solar.max_power) * 100, 100) ,0);
const PV1Efficiency = (!config.solar.pv1_max_power || config.solar.efficiency === 0) ? 100 : Utils.toNum(Math.min((pv1PowerWatts / config.solar.pv1_max_power) * 100, 100) ,0);
const PV2Efficiency = (!config.solar.pv2_max_power || config.solar.efficiency === 0) ? 100 : Utils.toNum(Math.min((pv2PowerWatts / config.solar.pv2_max_power) * 100, 100) ,0);
const PV3Efficiency = (!config.solar.pv3_max_power || config.solar.efficiency === 0) ? 100 : Utils.toNum(Math.min((pv3PowerWatts / config.solar.pv3_max_power) * 100, 100) ,0);
const PV4Efficiency = (!config.solar.pv4_max_power || config.solar.efficiency === 0) ? 100 : Utils.toNum(Math.min((pv4PowerWatts / config.solar.pv4_max_power) * 100, 100) ,0);
/**
* The current structure of this data object is intentional, but it is considered temporary.
* There is a need to evaluate the data being passed, as there might be duplication.
Expand Down Expand Up @@ -1081,7 +1092,12 @@ export class SunsynkPowerFlowCard extends LitElement {
auxDynamicColour,
auxDynamicColourLoad1,
auxDynamicColourLoad2,
stateMaxSellPower
stateMaxSellPower,
totalPVEfficiency,
PV1Efficiency,
PV2Efficiency,
PV3Efficiency,
PV4Efficiency
};

if (this.isFullCard) {
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Omezení"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -110,6 +108,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Navn",
"pv4_name": "PV4 Navn",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Batteri",
"load1_name": "Load 1 Navn",
"load2_name": "Load 2 Navn",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
1 change: 1 addition & 0 deletions src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
4 changes: 1 addition & 3 deletions src/localize/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Réseau",
"limit": "Limit"



},
"errors": {
"battery": {
Expand Down Expand Up @@ -110,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
1 change: 1 addition & 0 deletions src/localize/languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"pv3_name": "PFV3 Name",
"pv4_name": "PFV4 Name",
"display_mode": "Mode de Exibição",
"efficiency": "Efficiency Mode",
"battery": "Bateria",
"load1_name": "Nome Uso1",
"load2_name": "Nome Uso2",
Expand Down
3 changes: 1 addition & 2 deletions src/localize/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"


},
"errors": {
"battery": {
Expand Down Expand Up @@ -109,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
2 changes: 1 addition & 1 deletion src/localize/languages/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"sleepmode": "Sleep Mode",
"grid_name": "Grid",
"limit": "Limit"

},
"errors": {
"battery": {
Expand Down Expand Up @@ -108,6 +107,7 @@
"pv3_name": "PV3 Name",
"pv4_name": "PV4 Name",
"display_mode": "Display Mode",
"efficiency": "Efficiency Mode",
"battery": "Battery",
"load1_name": "Load 1 Name",
"load2_name": "Load 2 Name",
Expand Down
12 changes: 11 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ export interface sunsynkPowerFlowCardConfig extends LovelaceCardConfig {
animation_speed: number;
max_power: number;
pv1_name: string;
pv1_max_power: number,
pv2_name: string;
pv2_max_power: number,
pv3_name: string;
pv3_max_power: number,
pv4_name: string;
pv4_max_power: number,
auto_scale: boolean;
display_mode: number;
dynamic_colour: boolean;
efficiency: number;
}
load: {
colour: string;
Expand Down Expand Up @@ -430,5 +435,10 @@ export interface DataDto {
stateNonessentialLoad1: CustomEntity,
stateNonessentialLoad2: CustomEntity,
stateNonessentialLoad3: CustomEntity,
stateMaxSellPower: CustomEntity
stateMaxSellPower: CustomEntity,
totalPVEfficiency,
PV1Efficiency,
PV2Efficiency,
PV3Efficiency,
PV4Efficiency
}

0 comments on commit 7d80a50

Please sign in to comment.