[
{
"id": "940cc8addcfad1ae",
"type": "comment",
"z": "766610991b80293d",
"name": "Meteo.be",
"info": "",
"x": 120,
"y": 60,
"wires": []
},
{
"id": "9c907755cf793d56",
"type": "http request",
"z": "766610991b80293d",
"name": "Meteo.be",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 480,
"y": 100,
"wires": [
[
"e3ba358f99545aa8",
"9f1809c8cfb33afb"
]
]
},
{
"id": "ab4d51eec69c97e4",
"type": "inject",
"z": "766610991b80293d",
"name": "test",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 140,
"wires": [
[
"df11b9ae83dc4b2e"
]
]
},
{
"id": "e3ba358f99545aa8",
"type": "switch",
"z": "766610991b80293d",
"name": "Check Sts",
"property": "statusCode",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "200",
"vt": "num"
},
{
"t": "eq",
"v": "200",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 650,
"y": 100,
"wires": [
[
"bdcac97273a29fb5"
],
[
"ab56c6665fbb27ee",
"ebc2d1bbb85dc4ae"
]
]
},
{
"id": "bdcac97273a29fb5",
"type": "change",
"z": "766610991b80293d",
"name": "Status NOK",
"rules": [
{
"t": "set",
"p": "#:(file)::KMIStatus",
"pt": "global",
"to": "payload.response_status.error_code",
"tot": "msg"
},
{
"t": "set",
"p": "#:(file)::KMILastFetch",
"pt": "global",
"to": "0",
"tot": "num"
},
{
"t": "set",
"p": "#:(file)::KMILastFailed",
"pt": "global",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 850,
"y": 80,
"wires": [
[
"e3b7d6bd4f5bd408"
]
]
},
{
"id": "e3b7d6bd4f5bd408",
"type": "debug",
"z": "766610991b80293d",
"name": "Meteo Failed",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1170,
"y": 80,
"wires": []
},
{
"id": "08f9881e979e9dc8",
"type": "change",
"z": "766610991b80293d",
"name": "Status OK",
"rules": [
{
"t": "set",
"p": "#:(file)::KMIStatus",
"pt": "global",
"to": "Success",
"tot": "str"
},
{
"t": "set",
"p": "#:(file)::KMILastFetch",
"pt": "global",
"to": "",
"tot": "date"
},
{
"t": "set",
"p": "#:(file)::KMILastFailed",
"pt": "global",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 850,
"y": 120,
"wires": [
[
"2bf169adaf77e45d"
]
]
},
{
"id": "2bf169adaf77e45d",
"type": "debug",
"z": "766610991b80293d",
"name": "Meteo Success",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1180,
"y": 120,
"wires": []
},
{
"id": "ebc2d1bbb85dc4ae",
"type": "function",
"z": "766610991b80293d",
"name": "extract",
"func": "var pl=msg.payload;\n\nvar obj;\nobj = pl.features[0].properties.code;\nglobal.set(\"KMIStation\", obj, \"file\");\n\nvar objUTC;\n objUTC = new Date(pl.features[0].properties.timestamp); \nobj = objUTC.getTime();\nglobal.set(\"KMILastFetch\", obj, \"file\");\n\nobj = pl.features[0].properties.precip_quantity;\nglobal.set(\"KMI_precip_qty\", obj, \"file\");\nobj = pl.features[0].properties.precip_range;\nglobal.set(\"KMI_precip_range\", obj, \"file\");\n\nobj = pl.features[0].properties.temp;\nglobal.set(\"KMI_temp\", obj, \"file\");\nvar sqlTemp = obj;\n\nobj = pl.features[0].properties.temp_min;\nglobal.set(\"KMI_temp_min\", obj, \"file\");\nobj = pl.features[0].properties.temp_max;\nglobal.set(\"KMI_temp_max\", obj, \"file\");\nobj = pl.features[0].properties.wind_speed;\nglobal.set(\"KMI_wind_speed\", obj, \"file\");\nobj = pl.features[0].properties.wind_direction;\nglobal.set(\"KMI_wind_direction\", obj, \"file\");\nobj = pl.features[0].properties.wind_peak_speed;\nglobal.set(\"KMI_wind_peak_speed\", obj, \"file\");\nobj = pl.features[0].properties.humidity_relative;\nglobal.set(\"KMI_hum_rel\", obj, \"file\");\nobj = pl.features[0].properties.pressure;\nglobal.set(\"KMI_pressure\", obj, \"file\");\n\n// SQL\nmsg.payload = null;\nvar date = new Date(objUTC.getTime());\nvar tzo = date.getTimezoneOffset();\nvar time = date.getTime();\nvar utime = time + (tzo * 60000);\nvar udate = new Date(utime);\nvar uy = udate.getFullYear();\nvar um = udate.getMonth() + 1;\nvar ud = udate.getDate();\nvar uh = udate.getHours();\n\nvar sqldt = \"\" + uy + \"-\" + (\"0\"+um).slice(-2) + \"-\" + (\"0\"+ud).slice(-2) + \" \" + (\"0\"+uh).slice(-2) + \":\" + \"00:00\"\n\nmsg.topic = \"INSERT INTO AnnalesMonasterii (dateTime, KMI_temp) VALUES ('\" + sqldt + \"', \" + sqlTemp + \") \" +\n \"ON DUPLICATE KEY UPDATE KMI_temp = \" + sqlTemp + \";\"\n\nmsg.payload = { dd: new Date(), sqldt };\n\nreturn msg;\n\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 830,
"y": 160,
"wires": [
[
"b0f47fdd12759d1e",
"4021c85791ca985f",
"47e526e2378e5e76"
]
]
},
{
"id": "ab56c6665fbb27ee",
"type": "debug",
"z": "766610991b80293d",
"name": "debug 116",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 850,
"y": 220,
"wires": []
},
{
"id": "df11b9ae83dc4b2e",
"type": "function",
"z": "766610991b80293d",
"name": "set URL",
"func": "var date = new Date();\nvar tzo = date.getTimezoneOffset();\nvar time = date.getTime();\nvar utime = time + (tzo * 60000);\nvar udate = new Date(utime);\nvar uy = udate.getFullYear();\nvar um = udate.getMonth()+1;\nvar ud = udate.getDate();\nvar uh = udate.getHours();\n\n//kennelijk per uur. per 15 of 30 minuten zou ook moeten kunnen, maar nog niet gelukt\nvar strd = uy + \"-\" + (\"0\"+um).slice(-2) + \"-\" + (\"0\"+ud).slice(-2); \nvar strt = (\"0\"+uh).slice(-2) + \":00:00.000\"\nvar obj = strd + \" \" + strt;\n\nvar url = \"https://opendata.meteo.be/service/ows?service=WFS&version=2.0.0&request=GetFeature&typenames=synop:synop_data&outputformat=json&CQL_FILTER=((BBOX(the_geom,5.450296,50.915458,5.450296,50.915458,%20%27EPSG:4326%27))%20AND%20(timestamp%20%3E=%20%27\" + strd + \"%20\" + strt + \"%27%20AND%20timestamp%20%3C=%20%27\" + strd + \"%20\" + strt + \"%27))&sortby=timestamp\";\n\nmsg.url = url;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 320,
"y": 100,
"wires": [
[
"9c907755cf793d56",
"7c95d23cd9479615"
]
]
},
{
"id": "39208988d1e8879f",
"type": "inject",
"z": "766610991b80293d",
"name": "30 m",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "*/30 0-23 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 100,
"wires": [
[
"df11b9ae83dc4b2e"
]
]
},
{
"id": "4021c85791ca985f",
"type": "mysql",
"z": "766610991b80293d",
"mydb": "03a85ce256ca9d57",
"name": "",
"x": 1160,
"y": 160,
"wires": [
[]
]
},
{
"id": "9f1809c8cfb33afb",
"type": "debug",
"z": "766610991b80293d",
"name": "debug 117",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 220,
"wires": []
},
{
"id": "7c95d23cd9479615",
"type": "debug",
"z": "766610991b80293d",
"name": "debug 118",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 450,
"y": 220,
"wires": []
},
{
"id": "b0f47fdd12759d1e",
"type": "debug",
"z": "766610991b80293d",
"name": "debug Meteo extract",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1080,
"y": 220,
"wires": []
},
{
"id": "251d11861c1fa6ba",
"type": "comment",
"z": "766610991b80293d",
"name": "slechts 1x/h, maar lijkt enkel te werken per > hh:30",
"info": "",
"x": 370,
"y": 60,
"wires": []
},
{
"id": "47e526e2378e5e76",
"type": "file",
"z": "766610991b80293d",
"name": "to SSD",
"filename": "/mnt/ssd/node-red/DebugLog.txt",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 1030,
"y": 280,
"wires": [
[
"c2855fbd4cbbdf20"
]
]
},
{
"id": "c2855fbd4cbbdf20",
"type": "debug",
"z": "766610991b80293d",
"name": "debug 119",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1230,
"y": 280,
"wires": []
},
{
"id": "fe9600b37ad14c52",
"type": "comment",
"z": "766610991b80293d",
"name": "Debug 21:00 ???",
"info": "",
"x": 1120,
"y": 320,
"wires": []
},
{
"id": "03a85ce256ca9d57",
"type": "MySQLdatabase",
"name": "",
"host": "RPISANDBOX",
"port": "3306",
"db": "S8AB01",
"tz": "\"Europe/Brussels\"",
"charset": "UTF8"
}
]