First flow on all my RPIs

I found this flow helpfull and it is growing over time. It has a function library, global variables, some usefull cron nodes, a central http request, a telegram output etc....

[{"id":"b263e6b23d8eb759","type":"tab","label":"Sytem Services","disabled":false,"info":"","env":[]},{"id":"822527725c7dc5b4","type":"group","z":"b263e6b23d8eb759","name":"System Services","style":{"stroke":"#a4a4a4","label":true,"fill":"#ffefbf","fill-opacity":"0.18"},"nodes":["cefbc81259d60831","a80f530462abfacc","58724090944c5d8b","22f1b275fb4fa70a","d93a61053c3c1138","513342ae16ee393e","26c9933b5069f369","0ee6bc8cb3276b06","fa5af2fb16e3ed48"],"x":74,"y":871.5,"w":632,"h":349.5},{"id":"7d08e4b88b4a3571","type":"group","z":"b263e6b23d8eb759","name":"common routines","style":{"fill":"#ffdf7f","fill-opacity":"0.18","label":true,"stroke":"#ff0000"},"nodes":["3be6b85ac0c23e23"],"x":74,"y":59,"w":212,"h":82},{"id":"d164d05ea4dd9645","type":"group","z":"b263e6b23d8eb759","name":"Cron","style":{"label":true,"fill":"#d1d1d1","fill-opacity":"0.18"},"nodes":["f302da7022f63a58","b94d609007366f0c","d72b564df93d24b5","127c97edc66fd64f","528348829347db0e","9299e0dd8f240a0f"],"x":68,"y":193,"w":394,"h":634},{"id":"ea1db47bb61d9273","type":"group","z":"b263e6b23d8eb759","name":"central http-request","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["d59a2325dd14c795","e68047ac842dec83","94280fbadd4967bf","5ab34b4781bc1caf","3e71970ac957f920","f329bb9bfb89d858","2f9ad77be5d3ada8","14d66265c705c0b9","4d93b4cd3269cad2","85abc99c6ccb2211"],"x":74,"y":1419,"w":1202,"h":322},{"id":"0c7c436f8a5cc097","type":"group","z":"b263e6b23d8eb759","name":"error handling","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["734b1bf305b93e8c","fe2a97bef7fedda4","c138f086f072f326","1bcbad7b51596b08"],"x":84,"y":1799,"w":812,"h":142},{"id":"9c8b492f1fc2d348","type":"group","z":"b263e6b23d8eb759","name":"mqtt-gate","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["faad0d73ecc766ce","5d5e9bb1f0c15b1d","b1bbe9e9cb74e870","410808df5aa5ea71"],"x":74,"y":1279,"w":612,"h":82},{"id":"3dcd10e3f8ad3578","type":"group","z":"b263e6b23d8eb759","name":"Mesage to Telegram","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["d3422b90f8530fb4","331e55c6bd666f1f"],"x":84,"y":1979,"w":392,"h":82},{"id":"72aef3ef94af81bb","type":"group","z":"b263e6b23d8eb759","name":"gobal variables","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true,"stroke":"#ff0000"},"nodes":["f806f2a06355e854"],"x":414,"y":59,"w":212,"h":82},{"id":"f302da7022f63a58","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"Initialisation Impuls","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true,"color":"#777777","stroke":"#92d04f"},"nodes":["02bd72daa36044e5","925444abfd4bac79"],"x":94,"y":219,"w":342,"h":82},{"id":"b94d609007366f0c","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"wifi impuls","style":{"stroke":"#92d04f","label":true,"fill":"#ffefbf","fill-opacity":"0.18"},"nodes":["d3640db36fb6a565","bb594a95da5aee74"],"x":94,"y":319,"w":342,"h":82},{"id":"d72b564df93d24b5","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"firmware-impuls","style":{"stroke":"#92d04f","fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["5e6f80a5c869fa91","84f41c6a279dda87"],"x":94,"y":419,"w":342,"h":82},{"id":"127c97edc66fd64f","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"midnight-impuls","style":{"stroke":"#92d04f","fill":"#ffefbf","fill-opacity":"0.18","label":true},"nodes":["77e2c0bf1fad2b85","1ad7abcae08cbbbb"],"x":94,"y":519,"w":342,"h":82},{"id":"528348829347db0e","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"tick every minute","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true,"stroke":"#92d04f"},"nodes":["25770a19ef9e1974","fd43e771c5235497"],"x":94,"y":719,"w":342,"h":82},{"id":"9299e0dd8f240a0f","type":"group","z":"b263e6b23d8eb759","g":"d164d05ea4dd9645","name":"tick every second","style":{"fill":"#ffefbf","fill-opacity":"0.18","label":true,"stroke":"#92d04f"},"nodes":["ba92c0aa27ceef02","a67c763711582657"],"x":94,"y":619,"w":342,"h":82},{"id":"cefbc81259d60831","type":"inject","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"5Ghz-reset","payload":"","payloadType":"date","x":220,"y":1160,"wires":[["a80f530462abfacc","58724090944c5d8b"]]},{"id":"a80f530462abfacc","type":"mqtt out","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"","topic":"","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"dedee2f82d127c47","x":450,"y":1180,"wires":[]},{"id":"58724090944c5d8b","type":"function","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"reconnect WiFi","func":"msg.payload = \"sudo ip link set wlan0 down && sleep 1 && sudo ip link set wlan0 up\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":1140,"wires":[["22f1b275fb4fa70a"]]},{"id":"22f1b275fb4fa70a","type":"exec","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","command":"sudo","addpay":"payload","append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":630,"y":1140,"wires":[[],[],[]]},{"id":"d93a61053c3c1138","type":"inject","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1120,"wires":[["58724090944c5d8b"]]},{"id":"513342ae16ee393e","type":"inject","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1020,"wires":[["26c9933b5069f369"]]},{"id":"26c9933b5069f369","type":"exec","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","command":"node-red-restart","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":480,"y":1020,"wires":[[],[],[]]},{"id":"0ee6bc8cb3276b06","type":"exec","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","command":"sudo reboot","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":470,"y":920,"wires":[[],[],[]]},{"id":"fa5af2fb16e3ed48","type":"inject","z":"b263e6b23d8eb759","g":"822527725c7dc5b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":920,"wires":[["0ee6bc8cb3276b06"]]},{"id":"3be6b85ac0c23e23","type":"function","z":"b263e6b23d8eb759","g":"7d08e4b88b4a3571","name":"function library","func":"","outputs":1,"timeout":0,"noerr":0,"initialize":"// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\n\n//----------------------------------------------------------------------------------------------\n\ncontext.global.timestring = function (timestamp,format) {\n    const date = new Date(timestamp);\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    switch(format){\n        case \"HH:MM:SS @ DD-MM-YYYY\":\n            return (hours + ':' + minutes + ':' + seconds + \" @ \" + day + \"-\" + month + \"-\" + year);\n        case \"HH:MM:SS DD-MM-YYYY\":\n            return (hours + ':' + minutes + ':' + seconds + \" \" + day + \"-\" + month + \"-\" + year);  \n        case \"DD-MM-YYYY\":\n            return (day + \"-\" + month + \"-\" + year);\n        case \"HH:MM:SS\":\n            return (hours + ':' + minutes + ':' + seconds); \n        case \"HH:MM\":\n            return (hours + ':' + minutes);                                 \n    }\nreturn null;\n}\n\n//----------------------------------------------------------------------------------------------\n\ncontext.global.runtime_ms= function runtime_str(ms,format) {\n    const t = ms/1000;\n    const h = (Math.floor(t / 3600)).toString();\n    const m = (Math.floor(t % 3600 / 60)).toString();\n    const s = (Math.floor(t % 3600 % 60)).toString();\n    switch (format) {\n        case \"HH:MM:SS\":\n            return ((\"00\" + h).slice(-3) + \":\" + (\"0\" + m).slice(-2) + \":\" + (\"0\" + s).slice(-2));\n        case \"HH:MM\":\n            return ((\"00\" + h).slice(-3) + \":\" + (\"0\" + m).slice(-2));\n        case \"HH\":\n            return ((\"00\" + h).slice(-3));\n    }    \nreturn null;\n}\n\n//----------------------------------------------------------------------------------------------\n\ncontext.global.runtime_sec = function runtime_str(sec, format) {\n    const t = sec;\n    const h = (Math.floor(t / 3600)).toString();\n    const m = (Math.floor(t % 3600 / 60)).toString();\n    const s = (Math.floor(t % 3600 % 60)).toString();\n    switch (format) {\n        case \"HH:MM:SS\":\n            return ((\"00\" + h).slice(-3) + \":\" + (\"0\" + m).slice(-2) + \":\" + (\"0\" + s).slice(-2));\n        case \"HH:MM\":\n            return ((\"00\" + h).slice(-3) + \":\" + (\"0\" + m).slice(-2));\n        case \"HH\":\n            return ((\"00\" + h).slice(-3));\n    }\n    return null;\n}\n\n//----------------------------------------------------------------------------------------------\n\ncontext.global.rel_pressure = function runtime_str(pressure, hight) {\n    const x = 1 - (hight / 44330);    // hight[m] above sealevel\n    const y = 5.255;\n    return (parseFloat(pressure / Math.pow(x, y)).toFixed(1));\n}\n\n//----------------------------------------------------------------------------------------------\n","finalize":"","libs":[],"x":180,"y":100,"wires":[[]]},{"id":"02bd72daa36044e5","type":"inject","z":"b263e6b23d8eb759","g":"f302da7022f63a58","name":"central-init-impuls","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"{\"type\":\"init\"}","payloadType":"json","x":230,"y":260,"wires":[["925444abfd4bac79"]]},{"id":"925444abfd4bac79","type":"link out","z":"b263e6b23d8eb759","g":"f302da7022f63a58","name":"initialisation impuls","mode":"link","links":["88890ba844ff004e","29c9a044e58ccc08","49a4562c7ef0b43f","0fd8ccca192b7577","59a3529d627adf43","a096dcfe86f0d4c9","20f70f1f718d9da8","fc4c83408d322b06","c9ebcb1ea7fa5ec3","97caa6e3496ddbf2","6e58c6b0731ee429","c22cb9c519534951","5895a5aee192bb9b","7e7fc84225593a48","410808df5aa5ea71","f65536f11f669874","659e11fa6e765b8d","614f2cde083ad1ee","a30f3ba19a8c8cf6"],"x":395,"y":260,"wires":[]},{"id":"d59a2325dd14c795","type":"link in","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"http-request-in","links":["7425a2432b92bb18"],"x":115,"y":1580,"wires":[["5ab34b4781bc1caf","14d66265c705c0b9"]]},{"id":"e68047ac842dec83","type":"http request","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"central HTTP request","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":640,"y":1580,"wires":[["f329bb9bfb89d858"]]},{"id":"94280fbadd4967bf","type":"link out","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"http-request-out","mode":"return","links":[],"x":985,"y":1580,"wires":[]},{"id":"5ab34b4781bc1caf","type":"function","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"requestTimeout","func":"const to = 20000;               // request timeout in ms\nconst z = date_time_string();\n\nlet counter = context.get('counter') + 1;\nlet s = counter + \" | \" + z + \" | \" + msg.url + \" | \" + to + \"ms\";\nnode.status({ text: s });\ncontext.set('counter', counter);\nmsg.requestTimeout = to;\nreturn msg;\n\n//--------------------------------------------------------------------\n\nfunction date_time_string() {\n    const date = new Date(Date.now());\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = hours + ':' + minutes + ':' + seconds;\n    return datetimestring;\n}","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\ncontext.set(\"counter\", 0)\n","finalize":"","libs":[],"x":280,"y":1580,"wires":[["e68047ac842dec83"]]},{"id":"3e71970ac957f920","type":"debug","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"debug central http request ok","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":1460,"wires":[]},{"id":"f329bb9bfb89d858","type":"switch","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":1580,"wires":[["94280fbadd4967bf","3e71970ac957f920","4d93b4cd3269cad2"],["2f9ad77be5d3ada8","85abc99c6ccb2211"]]},{"id":"2f9ad77be5d3ada8","type":"debug","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"debug central http request error","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1100,"y":1700,"wires":[]},{"id":"14d66265c705c0b9","type":"debug","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"debug central http request input","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":330,"y":1520,"wires":[]},{"id":"4d93b4cd3269cad2","type":"function","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"request ok","func":"const z = date_time_string();\nlet counter = context.get('counter') + 1;\n\nlet url = msg.responseUrl;\nlet status = msg.statusCode;\nlet s = counter + \" | \" + z + \" | \" + msg.url + \" | \" + \"StatusCode \" + msg.statusCode;\nnode.status({ text: s });\n\ncontext.set('counter', counter);\nreturn msg;\n\n\n//--------------------------------------------------------------------\n\nfunction date_time_string() {\n    const date = new Date(Date.now());\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = hours + ':' + minutes + ':' + seconds;\n    return datetimestring;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\ncontext.set(\"counter\", 0)","finalize":"","libs":[],"x":1040,"y":1520,"wires":[[]]},{"id":"85abc99c6ccb2211","type":"function","z":"b263e6b23d8eb759","g":"ea1db47bb61d9273","name":"request error","func":"const z = date_time_string();\nlet counter = context.get('counter') + 1;\n\nlet url = msg.responseUrl;\nlet status = msg.statusCode;\nlet s = counter + \" | \" + z + \" | \" + msg.url + \" | \" + \"StatusCode \" + msg.statusCode;\nnode.status({ text: s });\n\ncontext.set('counter', counter);\nreturn msg;\n\n\n//--------------------------------------------------------------------\n\nfunction date_time_string() {\n    const date = new Date(Date.now());\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = hours + ':' + minutes + ':' + seconds;\n    return datetimestring;\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\ncontext.set(\"counter\", 0)","finalize":"","libs":[],"x":1040,"y":1640,"wires":[[]]},{"id":"734b1bf305b93e8c","type":"catch","z":"b263e6b23d8eb759","g":"0c7c436f8a5cc097","name":"All errors","scope":null,"uncaught":false,"x":170,"y":1860,"wires":[["c138f086f072f326"]]},{"id":"fe2a97bef7fedda4","type":"debug","z":"b263e6b23d8eb759","g":"0c7c436f8a5cc097","name":"debug central http request all errors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":1840,"wires":[]},{"id":"c138f086f072f326","type":"function","z":"b263e6b23d8eb759","g":"0c7c436f8a5cc097","name":"Time + Fehlermeldung","func":"let counter = context.get(\"counter\");\ncounter = counter + 1;\ncontext.set(\"counter\", counter);\n\nlet time = moment().tz(\"Europe/Berlin\").format(\"DD-MM-YYYY HH:mm:ss\");\n\nlet text = \"Fehlerzeitpunkt: \" + time + \" / \" +\n    \"RPI 67\" + \" / \" +\n    \"Flow: System Services\" + \" / \" +\n    \"Fehlermeldung: \" + msg.error.message + \" / \" +\n    \"Fehler ID: \" + msg.error.source.id + \" / \" +\n    \"Fehlertyp: \" + msg.error.source.type + \" / \" +\n    \"Fehlernode: \" + msg.error.source.name + \" / \" +\n    \"Fehlerzähler: \" + msg.error.source.count;\nnode.status({ fill: \"red\", shape: \"dot\", text: text + \" / \" + counter });\n\nreturn{payload:text};","outputs":1,"timeout":"","noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\nif (context.get(\"counter\") === undefined) {\n    context.set(\"counter\", 0);\n}","finalize":"","libs":[{"var":"moment","module":"moment"},{"var":"momentTimezone","module":"moment-timezone"}],"x":390,"y":1860,"wires":[["fe2a97bef7fedda4","1bcbad7b51596b08"]]},{"id":"d3640db36fb6a565","type":"inject","z":"b263e6b23d8eb759","g":"b94d609007366f0c","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":"2","topic":"wifi","x":190,"y":360,"wires":[["bb594a95da5aee74"]]},{"id":"77e2c0bf1fad2b85","type":"inject","z":"b263e6b23d8eb759","g":"127c97edc66fd64f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"midnight","x":210,"y":560,"wires":[["1ad7abcae08cbbbb"]]},{"id":"bb594a95da5aee74","type":"link out","z":"b263e6b23d8eb759","g":"b94d609007366f0c","name":"wifi-impuls","mode":"link","links":["9f71a7826bbd845c","7c796989b9e18e78","f37de5b9c6bf69de","1ea996a67bc57b41","37787759de432f82","5c763820bc9c01d7","05c18ead7cc8481b","d03a4af840cf5f38","ed6a02b634854f2c","4a6c80e2afc31fe7","c9619587b1e13e9d","e0b908e42ce04b9a"],"x":395,"y":360,"wires":[]},{"id":"1ad7abcae08cbbbb","type":"link out","z":"b263e6b23d8eb759","g":"127c97edc66fd64f","name":"midnight-impuls","mode":"link","links":["a72d32ca640adc6c","07bc7189dd03565b","903f35796f9b2ecf","3716492a68f7186c","d5b3e711b99718d2","a0e74f943102cf22","4cdd71927c9d79cc","872011fb2da2debe","0d8877a2b8916868","13366ca20fe03f35","2f7bc468b1a41444","670a24ff06f5502a"],"x":395,"y":560,"wires":[]},{"id":"5e6f80a5c869fa91","type":"inject","z":"b263e6b23d8eb759","g":"d72b564df93d24b5","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 01 * * *","once":true,"onceDelay":"2","topic":"firmware","x":210,"y":460,"wires":[["84f41c6a279dda87"]]},{"id":"84f41c6a279dda87","type":"link out","z":"b263e6b23d8eb759","g":"d72b564df93d24b5","name":"firmware-impuls","mode":"link","links":["933b9e49402dec56","12bedb220dff96c4","4a331f80bc47629e","fa7ee377f2e8b724","6b22138869d8db31","e9c1d851a04073ab","865db4ef606d032d","695975c19d605913","3dcce1907ee69853","dca3ecab3336d99d","41d45b645e09ca3c","ef24a0a2f50b63f4"],"x":395,"y":460,"wires":[]},{"id":"25770a19ef9e1974","type":"inject","z":"b263e6b23d8eb759","g":"528348829347db0e","name":"","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":true,"onceDelay":"70","topic":"","payload":"{\"type\":\"minuten-tick\"}","payloadType":"json","x":240,"y":760,"wires":[["fd43e771c5235497"]]},{"id":"fd43e771c5235497","type":"link out","z":"b263e6b23d8eb759","g":"528348829347db0e","name":"central-minuten-tick","mode":"link","links":["08a4a59cb50e33fe","3f01b6e07be4b515","59a3529d627adf43","0b49cb69239fdc6c"],"x":395,"y":760,"wires":[]},{"id":"ba92c0aa27ceef02","type":"inject","z":"b263e6b23d8eb759","g":"9299e0dd8f240a0f","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"{\"type\":\"sec-tick\"}","payloadType":"json","x":230,"y":660,"wires":[["a67c763711582657"]]},{"id":"a67c763711582657","type":"link out","z":"b263e6b23d8eb759","g":"9299e0dd8f240a0f","name":"central- sec-tick","mode":"link","links":["20f70f1f718d9da8","224234e628a6377e","35c42107fc2bed96","3ce22b69c24f73cd","5895a5aee192bb9b","6e58c6b0731ee429","714eccfcd7c886d5","97caa6e3496ddbf2","a096dcfe86f0d4c9","b553ea67c5080d15","c0773a796d6b53b6","c22cb9c519534951","c8dc097532e0e48e","c9ebcb1ea7fa5ec3","fc4c83408d322b06","fcb1a36e8862b717","b870f093b3bf1b3a"],"x":395,"y":660,"wires":[]},{"id":"faad0d73ecc766ce","type":"delay","z":"b263e6b23d8eb759","g":"9c8b492f1fc2d348","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":430,"y":1320,"wires":[["5d5e9bb1f0c15b1d"]]},{"id":"5d5e9bb1f0c15b1d","type":"function","z":"b263e6b23d8eb759","g":"9c8b492f1fc2d348","name":"function 6","func":"let t = date_time_string() + \" | \" + \"mqtt-gate open\";\nglobal.set('mqtt-gate', \"open\");\nnode.status({ text : t });\nreturn msg;\n\n//--------------------------------------------------------------------\n\nfunction date_time_string() {\n    const date = new Date(Date.now());\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = hours + ':' + minutes + ':' + seconds;\n    return datetimestring;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":1320,"wires":[[]]},{"id":"b1bbe9e9cb74e870","type":"function","z":"b263e6b23d8eb759","g":"9c8b492f1fc2d348","name":"function 7","func":"let t = date_time_string() + \" | \" + \"mqtt-gate closed\";\n// global.set('mqtt-gate', \"closed\");\nnode.status({ text : t });\nreturn msg;\n\n//--------------------------------------------------------------------\n\nfunction date_time_string() {\n    const date = new Date(Date.now());\n    const year = date.getFullYear();\n    const month = (\"0\" + (date.getMonth() + 1)).slice(-2);\n    const day = (\"0\" + date.getDate()).slice(-2);\n    const hours = (\"0\" + date.getHours()).slice(-2);\n    const minutes = (\"0\" + date.getMinutes()).slice(-2);\n    const seconds = (\"0\" + date.getSeconds()).slice(-2);\n    let datetimestring = hours + ':' + minutes + ':' + seconds;\n    return datetimestring;\n}","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\nglobal.set('mqtt-gate', \"closed\");","finalize":"","libs":[],"x":260,"y":1320,"wires":[["faad0d73ecc766ce"]]},{"id":"410808df5aa5ea71","type":"link in","z":"b263e6b23d8eb759","g":"9c8b492f1fc2d348","name":"link in 124","links":["925444abfd4bac79"],"x":115,"y":1320,"wires":[["b1bbe9e9cb74e870"]]},{"id":"d3422b90f8530fb4","type":"link in","z":"b263e6b23d8eb759","g":"3dcd10e3f8ad3578","name":"Telegram out","links":["c8d18d8c6b7db18b","e7ab0af7ca3e0907","6df3362876e00423","94cb739fe13fa005","1bcbad7b51596b08","de41e1a985c80387","63b6c264a5b52d13","cba985fa7f1e9b6c","25a71c6cb1d9d113","fcb4471ae45a688e"],"x":125,"y":2020,"wires":[["331e55c6bd666f1f"]]},{"id":"331e55c6bd666f1f","type":"mqtt out","z":"b263e6b23d8eb759","g":"3dcd10e3f8ad3578","name":"","topic":"send-to-Telegram","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"dedee2f82d127c47","x":360,"y":2020,"wires":[]},{"id":"f806f2a06355e854","type":"function","z":"b263e6b23d8eb759","g":"72aef3ef94af81bb","name":"global variables","func":"","outputs":1,"timeout":0,"noerr":0,"initialize":"// Der Code hier wird ausgeführt,\n// wenn der Node gestartet wird\n\nglobal.set('kWh_cost', 0.3488);","finalize":"","libs":[],"x":520,"y":100,"wires":[[]]},{"id":"1bcbad7b51596b08","type":"link out","z":"b263e6b23d8eb759","g":"0c7c436f8a5cc097","name":"link out 164","mode":"link","links":["d3422b90f8530fb4"],"x":585,"y":1900,"wires":[]},{"id":"dedee2f82d127c47","type":"mqtt-broker","name":"Home MQTT Server","broker":"10.0.0.43","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
1 Like

information regarding the library:
the library function seems to be a nice feature to reduce total programm size. Unforunately the functions within the library can not handle many calls that occur nearly at the same time. Therefore
I had to put time critical functions back to the flows.

Looking at an example in your function library:

context.global.rel_pressure = function runtime_str(pressure, hight) {
    const x = 1 - (hight / 44330);    // hight[m] above sealevel
    const y = 5.255;
    return (parseFloat(pressure / Math.pow(x, y)).toFixed(1));
}

How do you call this from another flow?

let p_rel = context.global.rel_pressure(980, 482);
482 = hight in meter

OK, that works thanks :grinning:

But what is this context.global.rel_pressure? It does not show up in the list of global context variables.

I think this is a context of node-red where they store the library and not a context of a function node

1 Like