[ { "id": "b016607a.570c28", "type": "tab", "label": "Weatherman", "disabled": false, "info": "" }, { "id": "47595dc.ba94324", "type": "tcp in", "z": "b016607a.570c28", "name": "Listen Weatherman", "server": "server", "host": "", "port": "8186", "datamode": "single", "datatype": "utf8", "newline": "", "topic": "", "base64": false, "x": 130, "y": 680, "wires": [ [ "ae8d6dda.86f638" ] ] }, { "id": "ae8d6dda.86f638", "type": "function", "z": "b016607a.570c28", "name": "Parse JSON", "func": "// customize basepath for the topic\n// the module type will be prepended\nconst basePath = '/status/';\n\n// customize basepath for info properties\n// the module type will be prepended\nconst basePathSys = '/info/';\n\nlet myTopic = '',\n myValue = '',\n myUnit = '',\n myType = '',\n myTime = '',\n myObject = '';\n\nconst myResults = [],\n myJSON = msg.payload;\n\n// Regex to match the unicode characters for EOT\nconst grepEOT = /(.*)(\\u0003|\\u0004)/;\nconst match = grepEOT.exec(myJSON);\n\n// String contains EOT, should be complete\nif (match !== null) {\n // Try to parse JSON and validate object\n myObject = JSON.parse(match[1]);\n if (myObject && typeof myObject === 'object') {\n const myObjectVars = myObject.vars;\n const arrayLength = myObjectVars.length;\n const moduleType = myObject.modultyp.toLowerCase();\n myTime = (new Date()).toLocaleString('de-DE');\n\n // loop through \"vars\" array\n for (let i = 0; i < arrayLength; i += 1) {\n myTopic = moduleType + basePath + myObjectVars[i].homematic_name;\n myUnit = myObjectVars[i].unit;\n myType = myObjectVars[i].type;\n\n // ensure correct type\n if (myType === 'number') {\n myValue = Number(myObjectVars[i].value);\n } else if (myType === 'string') {\n myValue = String(myObjectVars[i].value);\n } else if (myType === 'boolean') {\n (myObjectVars[i].value === 'true' ? myValue = true : myValue = false);\n }\n\n // Push values as objects into an array\n myResults.push({topic: myTopic, payload: myValue, unit: myUnit, timestamp: myTime});\n }\n\n // pass \"Systeminfo\" as object\n myTopic = moduleType + basePathSys;\n myValue = myObject.Systeminfo;\n\n // Push values as objects into an array\n myResults.push({topic: myTopic, payload: myValue, timestamp: myTime});\n\n // return array with the results as messages\n return [myResults];\n\n // Possibly truncated / corrupt message\n } else {\n node.error('Weatherman: Incomplete or corrupt JSON received', msg);\n }\n// No EOT found or parse error. Possibly truncated / corrupt message\n} else {\n node.error('Weatherman: Incomplete or corrupt JSON received', msg);\n}\n", "outputs": 1, "noerr": 0, "x": 330, "y": 680, "wires": [ [ "a47aee8c.f71c88", "70bdc0ab.57bb68", "dd404d55.4d0298", "9bfbbc02.2286", "11d0add3.735b3a", "1fd174e9.955d3b", "4b0e207b.f9a3a8", "eec14340.79e85", "ef55953c.2a9d8", "6164d528.cf0d84", "118d8092.a8adaf", "fbe364b8.e7a858", "b2f46e2f.031ba8", "4315c17.dc0774", "3836dbab.93bbec", "85a350e9.cc59d", "54d5512e.0b394", "dfcb9053.296238", "6c22d9a6.186f28", "2617b6e9.75f202", "5a395e80.61ad28", "dbbee228.7b6678", "dfadea41.67e", "edd899e.dc0c0e8", "fbe3e58.776dc98", "466dd9a1.ec0828", "d52eec66.eecd2" ] ], "outputLabels": [ "bla" ] }, { "id": "76b596e8.b0a7a8", "type": "ui_template", "z": "b016607a.570c28", "group": "cda55cb9.d73fc", "name": "Temperatur", "order": 0, "width": "3", "height": "6", "format": "\n\n\n", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "local", "x": 770, "y": 180, "wires": [ [] ] }, { "id": "762ab434.62a9c4", "type": "comment", "z": "b016607a.570c28", "name": "Weatherman", "info": "", "x": 110, "y": 60, "wires": [] }, { "id": "f2032b6f.a4ac7", "type": "comment", "z": "b016607a.570c28", "name": "Weatherman - Values", "info": "", "x": 600, "y": 140, "wires": [] }, { "id": "9892c742.9c59d", "type": "comment", "z": "b016607a.570c28", "name": "Weatherman - System Info", "info": "", "x": 610, "y": 1280, "wires": [] }, { "id": "4b9f5645.09b9", "type": "ui_template", "z": "b016607a.570c28", "group": "8132d18c.052bd", "name": "Load required scripts", "order": 3, "width": 0, "height": 0, "format": "\n\n\n", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "global", "x": 140, "y": 100, "wires": [ [] ] }, { "id": "a47aee8c.f71c88", "type": "switch", "z": "b016607a.570c28", "name": "w_temperatur", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_temperatur", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 180, "wires": [ [ "76b596e8.b0a7a8" ] ] }, { "id": "4b0e207b.f9a3a8", "type": "switch", "z": "b016607a.570c28", "name": "w_windchill", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_windchill", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 220, "wires": [ [] ] }, { "id": "eec14340.79e85", "type": "switch", "z": "b016607a.570c28", "name": "w_taupunkt", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_taupunkt", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 260, "wires": [ [] ] }, { "id": "ef55953c.2a9d8", "type": "switch", "z": "b016607a.570c28", "name": "w_himmeltemperatur", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_himmeltemperatur", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 600, "y": 300, "wires": [ [] ] }, { "id": "6164d528.cf0d84", "type": "switch", "z": "b016607a.570c28", "name": "w_feuchte_rel", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_feuchte_rel", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 340, "wires": [ [] ] }, { "id": "118d8092.a8adaf", "type": "switch", "z": "b016607a.570c28", "name": "w_feuchte_abs", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_feuchte_abs", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 380, "wires": [ [] ] }, { "id": "fbe364b8.e7a858", "type": "switch", "z": "b016607a.570c28", "name": "w_regensensor_wert", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regensensor_wert", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 600, "y": 420, "wires": [ [] ] }, { "id": "b2f46e2f.031ba8", "type": "switch", "z": "b016607a.570c28", "name": "w_regenmelder", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regenmelder", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 460, "wires": [ [] ] }, { "id": "4315c17.dc0774", "type": "switch", "z": "b016607a.570c28", "name": "w_regenstaerke", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regenstaerke", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 500, "wires": [ [] ] }, { "id": "3836dbab.93bbec", "type": "switch", "z": "b016607a.570c28", "name": "w_regen_letzte_h", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regen_letzte_h", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 590, "y": 540, "wires": [ [] ] }, { "id": "2617b6e9.75f202", "type": "switch", "z": "b016607a.570c28", "name": "w_regen_mm_heute", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regen_mm_heute", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 600, "y": 580, "wires": [ [] ] }, { "id": "5a395e80.61ad28", "type": "switch", "z": "b016607a.570c28", "name": "w_regenstunden_heute", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_regenstunden_heute", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 610, "y": 620, "wires": [ [] ] }, { "id": "1fd174e9.955d3b", "type": "switch", "z": "b016607a.570c28", "name": "w_barometer", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_barometer", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 660, "wires": [ [ "2a6c8b35.51fe3c" ] ] }, { "id": "85a350e9.cc59d", "type": "switch", "z": "b016607a.570c28", "name": "w_barotrend", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_barotrend", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 700, "wires": [ [ "2a6c8b35.51fe3c" ] ] }, { "id": "dd404d55.4d0298", "type": "switch", "z": "b016607a.570c28", "name": "w_wind_mittel", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_wind_mittel", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 740, "wires": [ [ "f7f36707.4f1bb" ] ] }, { "id": "dfcb9053.296238", "type": "switch", "z": "b016607a.570c28", "name": "w_wind_spitze", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_wind_spitze", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 860, "wires": [ [] ] }, { "id": "54d5512e.0b394", "type": "switch", "z": "b016607a.570c28", "name": "w_windstaerke", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_windstaerke", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 820, "wires": [ [] ] }, { "id": "9bfbbc02.2286", "type": "switch", "z": "b016607a.570c28", "name": "w_windrichtung", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_windrichtung", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 780, "wires": [ [ "f7f36707.4f1bb" ] ] }, { "id": "6c22d9a6.186f28", "type": "switch", "z": "b016607a.570c28", "name": "w_lux", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_lux", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 550, "y": 940, "wires": [ [] ] }, { "id": "dbbee228.7b6678", "type": "switch", "z": "b016607a.570c28", "name": "w_sonne_diff_temp", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_sonne_diff_temp", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 590, "y": 980, "wires": [ [] ] }, { "id": "dfadea41.67e", "type": "switch", "z": "b016607a.570c28", "name": "w_sonne_scheint", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_sonne_scheint", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 590, "y": 1020, "wires": [ [] ] }, { "id": "edd899e.dc0c0e8", "type": "switch", "z": "b016607a.570c28", "name": "w_elevation", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_elevation", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 1060, "wires": [ [] ] }, { "id": "fbe3e58.776dc98", "type": "switch", "z": "b016607a.570c28", "name": "w_azimut", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_azimut", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 560, "y": 1100, "wires": [ [] ] }, { "id": "466dd9a1.ec0828", "type": "switch", "z": "b016607a.570c28", "name": "w_minuten_vor_sa", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_minuten_vor_sa", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 590, "y": 1140, "wires": [ [] ] }, { "id": "d52eec66.eecd2", "type": "switch", "z": "b016607a.570c28", "name": "w_minuten_vor_su", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_minuten_vor_su", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 590, "y": 1180, "wires": [ [] ] }, { "id": "70bdc0ab.57bb68", "type": "switch", "z": "b016607a.570c28", "name": "weatherman/info", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/info/", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 580, "y": 1320, "wires": [ [ "9f2dc47c.4a883", "b285ab0f.38d18" ] ] }, { "id": "9f2dc47c.4a883", "type": "change", "z": "b016607a.570c28", "name": "sec_seit_reset", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "$$.topic & 'sec_seit_reset'", "tot": "jsonata" }, { "t": "set", "p": "payload", "pt": "msg", "to": "payload.sec_seit_reset", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 780, "y": 1320, "wires": [ [ "5da1840e.018e54" ] ] }, { "id": "f7f36707.4f1bb", "type": "function", "z": "b016607a.570c28", "name": "WindData", "func": "'use strict';\n// Long term wind data in h\nconst limitLongTerm = 8;\n// Mid term wind data in h\nconst limitMediumTerm = 3;\n// Short term wind data in h\nconst limitShortTerm = 1;\n\n// Define context to store data across multiple messages\nvar windData = context.get('windData') || {};\nvar windVector = context.get('windVector') || [];\n\n// Collect both wind speed and wind direction\n// and store them in the context\nswitch (msg.topic) {\n case 'weatherman/status/w_windrichtung':\n windData.direction = msg.payload;\n context.set('windData', windData);\n msg = null;\n break;\n case 'weatherman/status/w_wind_mittel':\n windData.speed = msg.payload;\n context.set('windData', windData);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\n// Start processing the data once both speed and \n// direction are available\nif (windData.direction != null && windData.speed != null) {\n var LTdata = [],\n MTdata = [],\n STdata = [],\n LTresult = [],\n MTresult = [],\n STresult = [],\n windObj = {},\n LTmsg = {},\n MTmsg = {},\n STmsg = {};\n const LTlimit = Date.now() - (limitLongTerm * 3600 * 1000);\n const MTlimit = Date.now() - (limitMediumTerm * 3600 * 1000);\n const STlimit = Date.now() - (limitShortTerm * 3600 * 1000);\n\n // Generate an object out of speed, direction and \n // current time and store as array\n windObj = {[windData.direction]: windData.speed, timestamp: Date.now()};\n windVector.push(windObj);\n\n // Null context to again collect a pair of speed \n // and direction\n windData = null;\n context.set('windData', windData);\n\n // Create arrays with data only for the above defined\n // time ranges\n LTdata = windVector.filter((arr) => arr.timestamp > LTlimit);\n MTdata = LTdata.filter((arr) => arr.timestamp > MTlimit);\n STdata = MTdata.filter((arr) => arr.timestamp > STlimit);\n \n // Make sure that the context does not grow infinitly \n context.set('windVector', LTdata);\n \n // Get the sum of all wind speeds for the different\n // cardinal points and for the above defined \n // time ranges\n LTresult[0] = LTdata.map((item) => (isNaN(item.N) ? 0 : item.N)).reduce((prev, next) => prev + next);\n LTresult[1] = LTdata.map((item) => (isNaN(item.NE) ? 0 : item.NE)).reduce((prev, next) => prev + next);\n LTresult[2] = LTdata.map((item) => (isNaN(item.E) ? 0 : item.E)).reduce((prev, next) => prev + next);\n LTresult[3] = LTdata.map((item) => (isNaN(item.SE) ? 0 : item.SE)).reduce((prev, next) => prev + next);\n LTresult[4] = LTdata.map((item) => (isNaN(item.S) ? 0 : item.S)).reduce((prev, next) => prev + next);\n LTresult[5] = LTdata.map((item) => (isNaN(item.SW) ? 0 : item.SW)).reduce((prev, next) => prev + next);\n LTresult[6] = LTdata.map((item) => (isNaN(item.W) ? 0 : item.W)).reduce((prev, next) => prev + next);\n LTresult[7] = LTdata.map((item) => (isNaN(item.NW) ? 0 : item.NW)).reduce((prev, next) => prev + next);\n LTmsg.payload = LTresult;\n MTresult[0] = MTdata.map((item) => (isNaN(item.N) ? 0 : item.N)).reduce((prev, next) => prev + next);\n MTresult[1] = MTdata.map((item) => (isNaN(item.NE) ? 0 : item.NE)).reduce((prev, next) => prev + next);\n MTresult[2] = MTdata.map((item) => (isNaN(item.E) ? 0 : item.E)).reduce((prev, next) => prev + next);\n MTresult[3] = MTdata.map((item) => (isNaN(item.SE) ? 0 : item.SE)).reduce((prev, next) => prev + next);\n MTresult[4] = MTdata.map((item) => (isNaN(item.S) ? 0 : item.S)).reduce((prev, next) => prev + next);\n MTresult[5] = MTdata.map((item) => (isNaN(item.SW) ? 0 : item.SW)).reduce((prev, next) => prev + next);\n MTresult[6] = MTdata.map((item) => (isNaN(item.W) ? 0 : item.W)).reduce((prev, next) => prev + next);\n MTresult[7] = MTdata.map((item) => (isNaN(item.NW) ? 0 : item.NW)).reduce((prev, next) => prev + next);\n MTmsg.payload = MTresult;\n STresult[0] = STdata.map((item) => (isNaN(item.N) ? 0 : item.N)).reduce((prev, next) => prev + next);\n STresult[1] = STdata.map((item) => (isNaN(item.NE) ? 0 : item.NE)).reduce((prev, next) => prev + next);\n STresult[2] = STdata.map((item) => (isNaN(item.E) ? 0 : item.E)).reduce((prev, next) => prev + next);\n STresult[3] = STdata.map((item) => (isNaN(item.SE) ? 0 : item.SE)).reduce((prev, next) => prev + next);\n STresult[4] = STdata.map((item) => (isNaN(item.S) ? 0 : item.S)).reduce((prev, next) => prev + next);\n STresult[5] = STdata.map((item) => (isNaN(item.SW) ? 0 : item.SW)).reduce((prev, next) => prev + next);\n STresult[6] = STdata.map((item) => (isNaN(item.W) ? 0 : item.W)).reduce((prev, next) => prev + next);\n STresult[7] = STdata.map((item) => (isNaN(item.NW) ? 0 : item.NW)).reduce((prev, next) => prev + next);\n STmsg.payload = STresult;\n\n return [LTmsg, MTmsg, STmsg];\n}\n", "outputs": 3, "noerr": 0, "x": 780, "y": 760, "wires": [ [ "1c250c9.69932f3" ], [], [] ], "outputLabels": [ "LongTerm", "MidTerm", "ShortTerm" ] }, { "id": "1c250c9.69932f3", "type": "ui_template", "z": "b016607a.570c28", "group": "a681ba6d.52c098", "name": "Wind Rose (LT)", "order": 0, "width": "5", "height": "5", "format": "\n\n\n", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "local", "x": 960, "y": 740, "wires": [ [] ] }, { "id": "2a6c8b35.51fe3c", "type": "ui_template", "z": "b016607a.570c28", "group": "139638aa.aa1f7f", "name": "Barometer", "order": 0, "width": "5", "height": "5", "format": "\n\n\n", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "local", "x": 770, "y": 680, "wires": [ [] ] }, { "id": "9dcb0ea8.a8b6c", "type": "ui_template", "z": "b016607a.570c28", "group": "cda55cb9.d73fc", "name": "Windrichtung", "order": 0, "width": "5", "height": "5", "format": "\n\n\n", "storeOutMessages": true, "fwdInMessages": true, "templateScope": "local", "x": 770, "y": 900, "wires": [ [] ] }, { "id": "11d0add3.735b3a", "type": "switch", "z": "b016607a.570c28", "name": "w_wind_dir", "property": "topic", "propertyType": "msg", "rules": [ { "t": "eq", "v": "weatherman/status/w_wind_dir", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 570, "y": 900, "wires": [ [ "9dcb0ea8.a8b6c" ] ] }, { "id": "201b4985.43682e", "type": "catch", "z": "b016607a.570c28", "name": "Parse JSON Error", "scope": [ "ae8d6dda.86f638", "6ff5d495.9ca94c", "b1c34c3a.cf0f18" ], "x": 1470, "y": 1380, "wires": [ [ "9244ec75.3c531" ] ] }, { "id": "5da1840e.018e54", "type": "rbe", "z": "b016607a.570c28", "name": "WatchDog", "func": "rbe", "gap": "", "start": "", "inout": "out", "property": "payload", "x": 968, "y": 1320, "wires": [ [ "fac0c00d.98edc", "9c4bcfb1.a51cc8" ] ] }, { "id": "fac0c00d.98edc", "type": "trigger", "z": "b016607a.570c28", "op1": "true", "op2": "false", "op1type": "bool", "op2type": "bool", "duration": "2", "extend": true, "units": "min", "reset": "1", "bytopic": "all", "name": "TimeOut", "x": 1120, "y": 1280, "wires": [ [ "5b96201c.34d428" ] ] }, { "id": "9244ec75.3c531", "type": "ui_template", "z": "b016607a.570c28", "group": "5eeec4a7.36c72c", "name": "Weatherman Health", "order": 0, "width": "5", "height": "5", "format": "\n\n\n
\n | {{conStatus}} | \n
{{jsonStatus}} | \n|
Heart Beat {{msg.timestamp}} | \n