Skip to content

Commit

Permalink
fix state_battery_rated_capacity logic
Browse files Browse the repository at this point in the history
  • Loading branch information
slipx06 committed Mar 13, 2024
1 parent 0b2e329 commit dd9b8f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit dd9b8f1

Please sign in to comment.