From 03dbc5118cf8bcccdd6b8d7b04aa719987ca3f24 Mon Sep 17 00:00:00 2001 From: mentalilll Date: Sat, 24 Feb 2024 21:16:07 +0100 Subject: [PATCH] - Bugfix VPD Value - Bugfix toFixed Axes --- ha-vpd-chart.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ha-vpd-chart.js b/ha-vpd-chart.js index af56e00..8c8039d 100644 --- a/ha-vpd-chart.js +++ b/ha-vpd-chart.js @@ -118,7 +118,12 @@ class HaVpdChart extends HTMLElement { if (sensor.leaf_temperature !== undefined) { leafTemperature = hass.states[sensor.leaf_temperature].state; } - let vpd = hass.states[sensor.vpd].state || this.calculateVPD(parseFloat(leafTemperature), parseFloat(temperature), parseFloat(humidity)).toFixed(2) + let vpd; + if (sensor.vpd !== undefined) { + vpd = hass.states[sensor.vpd].state; + } else { + vpd = this.calculateVPD(parseFloat(leafTemperature), parseFloat(temperature), parseFloat(humidity)).toFixed(2); + } let card = document.createElement('ha-card'); card.innerHTML += `
@@ -201,7 +206,7 @@ class HaVpdChart extends HTMLElement { let hum = document.createElement('div'); hum.className = 'humidity-axis-label'; // Runden auf eine sinnvolle Anzahl von Dezimalstellen, z.B. 1 - hum.innerHTML = `${currentValue}%`; + hum.innerHTML = `${currentValue.toFixed(0)}%`; humidityAxis.appendChild(hum); } axes.appendChild(temperatureAxis);