From 6c3fae1c07889a7ba040cc28e9f56b18f1b4938c Mon Sep 17 00:00:00 2001 From: slipx06 Date: Mon, 17 Jul 2023 18:19:40 +0200 Subject: [PATCH] Update sunsynk-power-flow-card.js Remove default labels (load1, load2) for additional essential and nonessential loads. Centre align the additional essential load labels on the lite card to allow for longer labels Add attributes to the battery card config to specify the battery empty and battery full percentages to customise when the battery icon changes --- dist/sunsynk-power-flow-card.js | 40 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/dist/sunsynk-power-flow-card.js b/dist/sunsynk-power-flow-card.js index cbef3dc8..c7f511ca 100644 --- a/dist/sunsynk-power-flow-card.js +++ b/dist/sunsynk-power-flow-card.js @@ -222,6 +222,8 @@ class SunsynkPowerFlowCard extends LitElement { let priority = (config?.entities.priority_load_243 === 'no' || !config?.entities.priority_load_243) ? 'no' : stateObj25.state; let battery_power = (config?.battery?.invert_power === 'yes') ? parseInt(stateObj13.state) * -1 : parseInt(stateObj13.state); let height = config?.card_height || '396px' + let bat_full = config?.battery?.full_capacity || '80' + let bat_empty = config?.battery?.empty_capacity || '30' //let width = config?.card_width || '100%' //totalsolar = pv1_power_186 + pv2_power_187 + pv3_power_188 + pv4_power_189 @@ -526,11 +528,11 @@ class SunsynkPowerFlowCard extends LitElement { ${inverterStateMsg} Essential Essential - ${config?.load?.load1_name ? `${config.load.load1_name}` : 'Load 1' } + ${config?.load?.load1_name ? `${config.load.load1_name}` : '' } ${parseFloat(stateObj42.state).toFixed(0) ? parseFloat(stateObj42.state).toFixed(0) : '0'} W - ${config?.load?.load1_name ? `${config.load.load1_name}` : 'Load 2' } + ${config?.load?.load1_name ? `${config.load.load1_name}` : '' } ${parseFloat(stateObj42.state).toFixed(0) ? parseFloat(stateObj42.state).toFixed(0) : '0'} W - ${config?.load?.load2_name ? `${config.load.load2_name}` : 'Load 2' } + ${config?.load?.load2_name ? `${config.load.load2_name}` : '' } ${parseFloat(stateObj45.state).toFixed(0) ? parseFloat(stateObj45.state).toFixed(0) : '0'} W DAILY LOAD DAILY LOAD @@ -542,8 +544,8 @@ class SunsynkPowerFlowCard extends LitElement { DAILY GRID SELL ${config?.load?.aux_name ? `${config.load.aux_name}` : 'Auxiliary' } ${config?.grid?.nonessential_name ? `${config.grid.nonessential_name}` : 'Non Essential' } - ${config?.grid?.load1_name ? `${config.grid.load1_name}` : 'Load 1' } - ${config?.grid?.load2_name ? `${config.grid.load2_name}` : 'Load 2' } + ${config?.grid?.load1_name ? `${config.grid.load1_name}` : '' } + ${config?.grid?.load2_name ? `${config.grid.load2_name}` : '' } ${parseFloat(stateObj40.state).toFixed(0) ? parseFloat(stateObj40.state).toFixed(0) : '0'} W ${parseFloat(stateObj41.state).toFixed(0) ? parseFloat(stateObj41.state).toFixed(0) : '0'} W ${Autarky}% @@ -656,10 +658,10 @@ class SunsynkPowerFlowCard extends LitElement { - - - - + + + + this.handlePopup(e, config.entities.grid_connected_status_194)}> @@ -1003,11 +1005,11 @@ class SunsynkPowerFlowCard extends LitElement { ${Ratiop}% Autarky Ratio - ${config?.load?.load1_name ? `${config.load.load1_name}` : 'Load 1' } + ${config?.load?.load1_name ? `${config.load.load1_name}` : '' } ${parseFloat(stateObj42.state).toFixed(0) ? parseFloat(stateObj42.state).toFixed(0) : '0'} W - ${config?.load?.load1_name ? `${config.load.load1_name}` : 'Load 1' } + ${config?.load?.load1_name ? `${config.load.load1_name}` : '' } ${parseFloat(stateObj42.state).toFixed(0) ? parseFloat(stateObj42.state).toFixed(0) : '0'} W - ${config?.load?.load2_name ? `${config.load.load2_name}` : 'Load 2' } + ${config?.load?.load2_name ? `${config.load.load2_name}` : '' } ${parseFloat(stateObj45.state).toFixed(0) ? parseFloat(stateObj45.state).toFixed(0) : '0'} W @@ -1121,10 +1123,10 @@ class SunsynkPowerFlowCard extends LitElement { - - - - + + + + this.handlePopup(e, config.entities.grid_connected_status_194)}> @@ -1284,6 +1286,12 @@ class SunsynkPowerFlowCard extends LitElement { if (!config.battery.shutdown_soc) { throw new Error('Please include the battery shutdown_soc attribate and value e.g shutdown_soc: 20'); } + if (config.battery.full_capacity < 80) { + throw new Error('Full capacity needs to be between 80 and 100'); + } + if (config.battery.empty_capacity > 30) { + throw new Error('Empty capacity needs to be <= 30'); + } if (config.battery.show_daily === 'yes' && (!config.entities.day_battery_charge_70 || !config.entities.day_battery_discharge_71) ) { throw Error('Please include the day_battery_charge_70 and day_battery_discharge_71 attributes and entity IDs'); }