-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflows_APRS_Weather.json
1 lines (1 loc) · 6.29 KB
/
flows_APRS_Weather.json
1
[{"id":"b329fff8.2bbda","type":"template","z":"7a97935a.cf2564","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"user {{call}} pass {{aprspass}}\n{{callForMsg}}>APRS,TCPIP*:@{{daytime}}z{{lat}}/{{lon}}_{{windDir}}/{{windSpeed}}g{{windGust}}t{{temperature}}r{{rainLastHour}}p{{rainLast24}}P{{rainSinceMid}}h{{humidity}}b{{pressure}}{{comment}}\n","output":"str","x":780,"y":1420,"wires":[["571ad2d0.fed85c"]]},{"id":"b1297ac7.f77b08","type":"function","z":"7a97935a.cf2564","name":"convert","func":"if (typeof msg.payload.windDir !== 'undefined'){\n msg.windDir = padValue(msg.payload.windDir);\n}else{\n msg.windDir = \"...\";\n}\n\nif (typeof msg.payload.windSpeed !== 'undefined'){\n msg.windSpeed = padValue(convertKmhToMph(msg.payload.windSpeed));\n}else{\n msg.windSpeed = \"...\";\n}\n\nif(typeof msg.payload.windGust !== 'undefined'){\n msg.windGust = padValue(convertKmhToMph(msg.payload.windGust))\n}else{\n msg.windGust = \"...\";\n}\n\nif(typeof msg.payload.temperature !== 'undefined'){\n msg.temperature = padValue(convertCelsiusToFahrenheit(msg.payload.temperature));\n}else{\n msg.temperature = \"...\";\n}\n\nif(typeof msg.payload.rainLastHour !== 'undefined'){\n msg.rainLastHour = padValue(convertMmToInch(msg.payload.rainLastHour));\n}else{\n msg.rainLastHour = \"...\";\n}\n\nif(typeof msg.payload.rainLast24 !== 'undefined'){\n msg.rainLast24 = padValue(convertMmToInch(msg.payload.rainLast24));\n}else{\n msg.rainLast24 = \"...\";\n}\n\nif(typeof msg.payload.rainSinceMidnight !== 'undefined'){\n msg.rainSinceMid = padValue(convertMmToInch(msg.payload.rainSinceMidnight));\n}else{\n msg.rainSinceMid = \"...\";\n}\n\nif(typeof msg.payload.humidity !== 'undefined'){\n msg.humidity = convertHumidity(Math.round(msg.payload.humidity));\n}else{\n msg.humidity = \"..\";\n}\n\nif(typeof msg.payload.pressure !== 'undefined'){\n if (msg.pressureAbsolut){\n msg.pressure = pad5(Math.round(calcRealPressure(msg.payload.pressure,msg.payload.temperature,msg.sealevel) * 10));\n }else{\n msg.pressure = pad5(msg.payload.pressure * 10);\n }\n}else{\n msg.pressure = \"...\";\n}\n\nmsg.daytime = getDayTime();\n\nreturn msg;\n\n\n\nfunction calcRealPressure(pressure,temp,elevation){\n //if no temperature reading is given - use 20 for calculation of realPressure\n if(typeof temp !== 'undefined'){\n tempToUse = temp\n }else{\n tempToUse = 20;\n }\n \n\ta = (16000 + 64 * tempToUse);\n\tph = pressure * ((a + elevation)/(a - elevation))\n\treturn ph;\n}\n\nfunction getDayTime(){\n var d = new Date();\n day = pad2(d.getUTCDate());\n hour = pad2(d.getUTCHours());\n minutes = pad2(d.getUTCMinutes());\n \n return day + \"\" + hour + \"\" + minutes;\n}\n\nfunction convertCelsiusToFahrenheit(temp){\n return temp * 9/5 + 32;\n}\n\nfunction convertKmhToMph(kmh){\n return kmh * 0.621;\n}\n\nfunction convertHumidity(value){\n if (value >= 100){\n return \"00\";\n }else{\n return value;\n }\n}\n\nfunction convertMmToInch(value){\n return value * 0.03937 * 100;\n}\n\nfunction padValue(value){\n valueF = parseFloat(value);\n if (isNaN(valueF)){\n return \"...\"\n }\n stringvalue = \"\" + Math.abs(Math.round(valueF));\n len = stringvalue.length;\n isNeg = valueF < 0;\n if (len == 1){\n if (isNeg){\n return \"-0\" + stringvalue;\n }else{\n return \"00\" + stringvalue;\n }\n }else if (len == 2){\n if (isNeg){\n return \"-\" + stringvalue;\n }else{\n return \"0\" + stringvalue;\n }\n }else if (len == 3){\n return stringvalue;\n }\n}\n\nfunction pad2(n) {\n return n<10 ? '0'+n : n;\n}\nfunction pad5(n) {\n return n<10000 ? '0'+n : n;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":1420,"wires":[["b329fff8.2bbda"]]},{"id":"a2ac6beb.b3c248","type":"function","z":"7a97935a.cf2564","name":"configure","func":"msg.lat = \"4720.12N\" // z.B.: 4720.12N\nmsg.lon = \"01240.12E\" // z.B.: 01240.12E Wert muss genau so lang wie im Bsp sein - ev. mit 0 vorne-drann\nmsg.callForMsg = \"OE0XXX\" // Call für das das Wetter gemeldet werden soll\nmsg.call = \"OE0XXX\" // Call ohne Suffix für Authentifizierung am APRS Server\nmsg.aprspass = \"12345\" // Passwort für APRS\nmsg.comment = \"Nodered\" // Kommentar\nmsg.pressureAbsolut = true // Ob der Messwert in absolut vorliegt oder bereits höhenkorrigiert ist\nmsg.sealevel = 750; // Höhe über Meeresspiegel [m]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":1420,"wires":[["b1297ac7.f77b08"]]},{"id":"ca6ce51e.12d5b8","type":"comment","z":"7a97935a.cf2564","name":"Erklärung Messwerte","info":"benötigt werden folgende Werte unter folgenden Variablennamen (wenn die eigene Wetterstation gewisse Daten nicht erfasst - einfach Variablen nicht belegen\n\nmsg.payload.windDir\t\t// Windrichtung [Grad]\nmsg.payload.windSpeed\t\t// Windgeschwindigkeit [km/h]\nmsg.payload.windGust\t\t// Windspitze der letzten 5 Minuten [km/h]\nmsg.payload.temperature \t// Temperatur [°C]\nmsg.payload.rainLastHour\t// Regen der letzten Stunde [mm]\nmsg.payload.rainLast24\t\t// Regen der letzten 24h [mm]\nmsg.payload.rainSinceMidnight\t// Regenmenge seit Mitternacht [mm]\nmsg.payload.humidity\t\t// Luftfeuchtigkeit [%]\nmsg.payload.pressure\t\t// Luftdruck [mbar]","x":240,"y":1380,"wires":[]},{"id":"1a621c68.b57d54","type":"function","z":"7a97935a.cf2564","name":"Werte von Quelle lesen","func":"msg.payload = {};\n//msg.payload.pressure = ;\n//msg.payload.temperature = \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":1420,"wires":[["a2ac6beb.b3c248"]]},{"id":"571ad2d0.fed85c","type":"tcp out","z":"7a97935a.cf2564","host":"44.143.43.90","port":"14580","beserver":"client","base64":false,"end":false,"name":"","x":990,"y":1420,"wires":[]}]