From c7a5ca719b274cf2b7f6440d97cb9bdc91167739 Mon Sep 17 00:00:00 2001 From: SirUlbrich Date: Thu, 12 Dec 2024 12:18:19 +0100 Subject: [PATCH] update --- custom-energy-card.js | 37 ++++++++++++++++++++++++++++--------- dist/custom-energy-card.js | 2 +- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/custom-energy-card.js b/custom-energy-card.js index d31c663..634d4bb 100644 --- a/custom-energy-card.js +++ b/custom-energy-card.js @@ -90,6 +90,12 @@ class CustomEnergyCard extends LitElement { else if (!config.pv1) { throw new Error('pv1 fehlt'); } + else if (!config.pv2) { + throw new Error('pv2 fehlt'); + } + else if (!config.pv3) { + throw new Error('pv3 fehlt'); + } else if (!config.consumption) { throw new Error('consumption fehlt'); } @@ -106,10 +112,12 @@ class CustomEnergyCard extends LitElement { const solarState = this.hass.states[this._config.solar]; const pv1State = this.hass.states[this._config.pv1]; + const pv2State = this.hass.states[this._config.pv2]; + const pv3State = this.hass.states[this._config.pv3]; const consumptionState = this.hass.states[this._config.consumption]; if (!solarState) { - return html` Unknown entity: ${this._config.solar} `; + return html` Unknown Solar: ${this._config.solar} `; } // @click below is also LitElement magic @@ -125,23 +133,35 @@ class CustomEnergyCard extends LitElement { ${pv1State && pv1State.state ? html`
-
☀️ PV1
-
${pv1State ? pv1State.state : "N/A"}
+
☀️ PV1
+
${pv1State ? pv1State.state : "N/A"}
+ + +
` : null } +
+
☀️ PV2
+
${pv2State ? pv2State.state : "N/A"}
+ +
+
+
☀️ PV3
+
${pv3State ? pv3State.state : "N/A"}
+ + + +
+
Netz
⚡ Consumption
${consumptionState ? consumptionState.state : "N/A"}
-
Netz
-
PV3
-
PV2
- - + @@ -170,7 +190,6 @@ class CustomEnergyCard extends LitElement { // Function to get the center of a box function getBox(box) { - if (!box) return null; const rect = box.getBoundingClientRect(); return { lx: rect.left, diff --git a/dist/custom-energy-card.js b/dist/custom-energy-card.js index ebb48d8..634d4bb 100644 --- a/dist/custom-energy-card.js +++ b/dist/custom-energy-card.js @@ -117,7 +117,7 @@ class CustomEnergyCard extends LitElement { const consumptionState = this.hass.states[this._config.consumption]; if (!solarState) { - return html` Unknown entity: ${this._config.solar} `; + return html` Unknown Solar: ${this._config.solar} `; } // @click below is also LitElement magic