From 3f7c501340f5c8d6ab52f507ded992c1fad262a3 Mon Sep 17 00:00:00 2001 From: Moritz Graf Date: Fri, 3 Jul 2026 11:54:23 +0200 Subject: [PATCH] fix(shelly): fix BLE variable overwriting bug in checkBlu --- terraform_shelly/scripts/Taupi-4.0.js | 36 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/terraform_shelly/scripts/Taupi-4.0.js b/terraform_shelly/scripts/Taupi-4.0.js index 0e67991..905d351 100644 --- a/terraform_shelly/scripts/Taupi-4.0.js +++ b/terraform_shelly/scripts/Taupi-4.0.js @@ -136,19 +136,35 @@ function checkBlu(event) { } if (addr === aussen) { - temperatur_aussen = event.temperature; - humidity_aussen = event.humidity; - taupunkt_aussen = taupunkt(event.temperature, event.humidity); - battery_aussen = event.battery; + if (typeof event.temperature !== "undefined") { + temperatur_aussen = event.temperature; + } + if (typeof event.humidity !== "undefined") { + humidity_aussen = event.humidity; + } + if (typeof temperatur_aussen !== "undefined" && typeof humidity_aussen !== "undefined") { + taupunkt_aussen = taupunkt(temperatur_aussen, humidity_aussen); + } + if (typeof event.battery !== "undefined") { + battery_aussen = event.battery; + } lost_connection_aussen = 0; - print("Neue Werte für Außen:", temperatur_aussen, "°C,", humidity_aussen, "%, Tp:", taupunkt_aussen, "°C, Batt: ", battery_aussen, " % "); + print("Neue Werte für Außen: T=", temperatur_aussen, "°C, RH=", humidity_aussen, "%, Tp=", taupunkt_aussen, "°C, Batt=", battery_aussen, "%"); } else if (addr === innen) { - temperatur_innen = event.temperature; - humidity_innen = event.humidity; - taupunkt_innen = taupunkt(event.temperature, event.humidity); - battery_innen = event.battery; + if (typeof event.temperature !== "undefined") { + temperatur_innen = event.temperature; + } + if (typeof event.humidity !== "undefined") { + humidity_innen = event.humidity; + } + if (typeof temperatur_innen !== "undefined" && typeof humidity_innen !== "undefined") { + taupunkt_innen = taupunkt(temperatur_innen, humidity_innen); + } + if (typeof event.battery !== "undefined") { + battery_innen = event.battery; + } lost_connection_innen = 0; - print("Neue Werte für Innen:", temperatur_innen, "°C,", humidity_innen, "%, Tp:", taupunkt_innen, "°C, Batt: " , battery_innen, " % "); + print("Neue Werte für Innen: T=", temperatur_innen, "°C, RH=", humidity_innen, "%, Tp=", taupunkt_innen, "°C, Batt=", battery_innen, "%"); } }