From dd9b8f1223aa0b5bde86efcf748e6f8353f2b971 Mon Sep 17 00:00:00 2001 From: Paul Orffer Date: Wed, 13 Mar 2024 18:58:42 +0200 Subject: [PATCH] fix state_battery_rated_capacity logic --- src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index de40c4b8..cb1e9eb6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -142,8 +142,8 @@ export class SunsynkPowerFlowCard extends LitElement { const state_battery_current = this.getEntity('battery_current_191'); const state_battery_temp = this.getEntity('battery_temp_182', {state: ''}); const state_battery_status = this.getEntity('battery_status', {state: ''}); - const state_battery_current_direction = this.getEntity('battery_current_direction', null); - const state_battery_rated_capacity = this.getEntity('battery_rated_capacity', null); + const state_battery_current_direction = this.getEntity('battery_current_direction', {state: ''}); + const state_battery_rated_capacity = this.getEntity('battery_rated_capacity', {state: ''}); //Load const state_essential_power = this.getEntity('essential_power'); @@ -576,8 +576,8 @@ export class SunsynkPowerFlowCard extends LitElement { const battenergy = this.getEntity('battery.energy', {state: config.battery.energy.toString() ?? ''}); let battery_energy = battenergy.toNum(0); - if (battery_voltage && state_battery_rated_capacity) { - battery_energy = Utils.toNum(battery_voltage * state_battery_rated_capacity.toNum(), 0) + if (battery_voltage && state_battery_rated_capacity.notEmpty()) { + battery_energy = Utils.toNum(battery_voltage * state_battery_rated_capacity.toNum(0), 0) } if (config.show_battery || battery_energy !== 0) {