Skip to content

Commit

Permalink
Merge pull request #39 from DanteWinters/develop
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
DanteWinters authored Oct 2, 2023
2 parents bdefccd + cbed74c commit 1de3da2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions config-entity-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,15 @@ export function getEntitiesState(config, hass, config_entity, index) {
}
}

export function getEntitiesNumState(config, hass, config_entity, index, is_int = true) {
export function getEntitiesNumState(config, hass, config_entity, index, is_int = true, is_avg = false) {
let value = 0;
if (index == -1) {
for (let i = 0; i < config.inverter_count; i++) {
value += parseFloat(getEntitiesState(config, hass, config_entity, i));
}
value = value / config.inverter_count;
if (is_avg) {
value = value / config.inverter_count;
}
} else {
value = parseFloat(getEntitiesState(config, hass, config_entity, index));
}
Expand Down
13 changes: 9 additions & 4 deletions lux-power-distribution-card.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { LitElement } from "https://unpkg.com/lit?module";

import * as cef from "./config-entity-functions.js";
import * as hf from "./html-functions.js";
import * as constants from "./constants.js";

class LuxPowerDistributionCard extends HTMLElement {
class LuxPowerDistributionCard extends LitElement {
set hass(hass) {
this._hass = hass;

Expand Down Expand Up @@ -250,7 +252,7 @@ class LuxPowerDistributionCard extends HTMLElement {
}

updateBattery(index) {
let battery_soc = cef.getEntitiesNumState(this.config, this._hass, "battery_soc", index);
let battery_soc = cef.getEntitiesNumState(this.config, this._hass, "battery_soc", index, true, true);
let battery_flow = cef.getEntitiesNumState(this.config, this._hass, "battery_flow", index);
const battery_arrow_element = this.card.querySelector("#battery-arrows");
// Image
Expand Down Expand Up @@ -291,7 +293,8 @@ class LuxPowerDistributionCard extends HTMLElement {
this._hass,
"battery_voltage",
index,
false
false,
true
)} Vdc (avg)`;
}
const battery_soc_info_element = this.card.querySelector("#battery-soc-info");
Expand Down Expand Up @@ -353,7 +356,9 @@ class LuxPowerDistributionCard extends HTMLElement {
this.config,
this._hass,
"grid_voltage",
index
index,
false,
true
)} Vac (avg)${grid_emoji}`;
}
}
Expand Down

0 comments on commit 1de3da2

Please sign in to comment.