mickym sagte in Node-Red Javascript Node - Berechnung ungewünscht doppelt:
var tempf = context.get('tempf')|| 0;
var humidity = context.get('humidity')|| 0;
var oldTp = context.get('contexttp') || 0;
var tp = 0;if (msg.topic === "tempf") {
tempf= msg.payload;
context.set('tempf',msg.payload);} else if (msg.topic === "humidity") {
humidity= msg.payload;
context.set('humidity',msg.payload);
}// Quelle: https://www.chemie-schule.de/KnowHow/Taupunkt
// Gültigkeitsbereich Taupunkt: -30°C <= tmp <= 70°C
if (!(isNaN(tempf) || isNaN(humidity))) {
tp = ((241.2 * Math.log(humidity/100)) + ((4222.03716 * tempf) / (241.2 + tempf))) / (17.5043 - Math.log(humidity/100) - ((17.5043*tempf)/(241.2+tempf)));
tp = Math.round( tp * 100 ) / 100;
context.set("contexttp",tp);
}if (oldTp !== tp) {
msg.payload = tp;
msg.topic = "Taupunkt";
return msg }
else {
return null;
}
Funktioniert auch... nun habe ich estmal was zum weiterspielen/testen... Vielen Dank erstmal!
Den Link/Quelle zu diesem Beitrag werde ich gleich mal im Script notieren....