From a95a1833cbc1da9a1dc11b95fd79f36e899b578a Mon Sep 17 00:00:00 2001 From: wrfz <77174685+wrfz@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:36:23 +0100 Subject: [PATCH] Fix error when "durchfluss" entity is not defined --- dist/hpsu-dashboard-card.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dist/hpsu-dashboard-card.js b/dist/hpsu-dashboard-card.js index f0634d3..206bc17 100644 --- a/dist/hpsu-dashboard-card.js +++ b/dist/hpsu-dashboard-card.js @@ -247,20 +247,13 @@ class HPSUDashboardCard extends HTMLElement { if (!flowArrows || !flowReturnArrows || !heatingArrows) return; - //console.log(this.config); - const flow_rate_id = this.config.entities['durchfluss']; const mixer_id = this.config.entities['mischer']; const bypass_id = this.config.entities['bypass']; - //console.log("flow_rate_id: " + flow_rate_id); - //console.log("mixer_id: " + mixer_id); - //console.log("bypass_id: " + bypass_id); - //console.log(this._hass.states); - - const flowRate = flow_rate_id ? parseFloat(this._hass.states[flow_rate_id].state) : 0; - const mischerState = mixer_id ? parseFloat(this._hass.states[mixer_id].state) : 0; - const bpvState = bypass_id ? parseFloat(this._hass.states[bypass_id].state) : 0; + const flowRate = flow_rate_id && this._hass.states[flow_rate_id] ? parseFloat(this._hass.states[flow_rate_id].state) : 0; + const mischerState = mixer_id && this._hass.states[mixer_id] ? parseFloat(this._hass.states[mixer_id].state) : 0; + const bpvState = bypass_id && this._hass.states[bypass_id] ? parseFloat(this._hass.states[bypass_id].state) : 0; flowArrows.style.opacity = flowRate > 0 ? (mischerState / 100.0) : 0; flowReturnArrows.style.opacity = flowRate > 0 ? (bpvState / 100.0) : 0;