Thank you so much! This is exact what i needed, and it works perfectly.
This is my Node-Red code:
[{"id":"eb41f62a.95ba98","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"75755866.201688","type":"OpcUa-Client","z":"eb41f62a.95ba98","endpoint":"38f7b58f.008a3a","action":"write","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"","securitymode":"None","securitypolicy":"None","name":"","x":1140,"y":120,"wires":[[]]},{"id":"a1b662e9.e803","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rTemperature_1h","datatype":"Float Array","value":"","name":"OPC","x":830,"y":100,"wires":[["75755866.201688"]]},{"id":"f81cd48d.23e4a8","type":"inject","z":"eb41f62a.95ba98","name":"","props":[{"p":"headers","v":"{\"User-Agent\":\"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0\"}","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":190,"y":100,"wires":[["4ae770a8.b0b25"]]},{"id":"4ae770a8.b0b25","type":"http request","z":"eb41f62a.95ba98","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.met.no/weatherapi/locationforecast/2.0/complete?altitude=75&lat=59.0234&lon=6.0413","tls":"","persist":false,"proxy":"","authType":"","x":370,"y":100,"wires":[["94e0fbd1.9af298","78504d54.e46254","1dc7854a.d71ddb","b20c9e7e.00aa","44ca5608.b504b8","1e086a2a.a9c4f6","65462d81.bbcca4","230afe63.3a8562"]]},{"id":"94e0fbd1.9af298","type":"function","z":"eb41f62a.95ba98","name":"Temperature 1h","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.instant.details.air_temperature != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Temperature_1h = filtered.map(e => {\n try {\n return e.data.instant.details.air_temperature;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Temperature_1h;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":100,"wires":[["a1b662e9.e803"]]},{"id":"b8936261.c1c2c","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rPrecipitation_1h","datatype":"Float Array","value":"","name":"OPC","x":830,"y":160,"wires":[["75755866.201688"]]},{"id":"78504d54.e46254","type":"function","z":"eb41f62a.95ba98","name":"Precipitation 1h","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_1_hours.details.precipitation_amount != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Precipitation_1h = filtered.map(e => {\n try {\n return e.data.next_1_hours.details.precipitation_amount;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Precipitation_1h;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":160,"wires":[["b8936261.c1c2c"]]},{"id":"c16de603.9be4a8","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rProbability_1h","datatype":"Float Array","value":"","name":"OPC","x":830,"y":220,"wires":[["75755866.201688"]]},{"id":"1dc7854a.d71ddb","type":"function","z":"eb41f62a.95ba98","name":"Probability 1h","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_1_hours.details.probability_of_precipitation != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Probability_1h = filtered.map(e => {\n try {\n return e.data.next_1_hours.details.probability_of_precipitation;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Probability_1h;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":220,"wires":[["c16de603.9be4a8"]]},{"id":"6f9a2322.b558ac","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rTemperature_6h_max","datatype":"Float Array","value":"","name":"OPC","x":830,"y":400,"wires":[["75755866.201688"]]},{"id":"b20c9e7e.00aa","type":"function","z":"eb41f62a.95ba98","name":"Tempereture 6h max","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_6_hours.details.air_temperature_max != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Temperature_6h_max = filtered.map(e => {\n try {\n return e.data.next_6_hours.details.air_temperature_max;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Temperature_6h_max;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":400,"wires":[["6f9a2322.b558ac"]]},{"id":"f53a0c51.6485c","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rPrecipitation_6h","datatype":"Float Array","value":"","name":"OPC","x":830,"y":280,"wires":[["75755866.201688"]]},{"id":"44ca5608.b504b8","type":"function","z":"eb41f62a.95ba98","name":"Precipitation 6h","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_6_hours.details.precipitation_amount != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Precipitation_6h = filtered.map(e => {\n try {\n return e.data.next_6_hours.details.precipitation_amount;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Precipitation_6h;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":280,"wires":[["f53a0c51.6485c"]]},{"id":"4e21e000.5598a","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rProbability_6h","datatype":"Float Array","value":"","name":"OPC","x":830,"y":340,"wires":[["75755866.201688"]]},{"id":"1e086a2a.a9c4f6","type":"function","z":"eb41f62a.95ba98","name":"Probability 6h","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_6_hours.details.probability_of_precipitation != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Probability_6h = filtered.map(e => {\n try {\n return e.data.next_6_hours.details.probability_of_precipitation;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Probability_6h;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":340,"wires":[["4e21e000.5598a"]]},{"id":"65462d81.bbcca4","type":"debug","z":"eb41f62a.95ba98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":40,"wires":[]},{"id":"49198fa4.c79ce","type":"OpcUa-Item","z":"eb41f62a.95ba98","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rTemperature_6h_min","datatype":"Float Array","value":"","name":"OPC","x":830,"y":460,"wires":[["75755866.201688"]]},{"id":"230afe63.3a8562","type":"function","z":"eb41f62a.95ba98","name":"Tempereture 6h min","func":"var originalArray = msg.payload.properties.timeseries;\nvar sliced = originalArray.slice(0, 85);\n\n//filter out items without air_temperature \nvar filtered = sliced.filter(e => {\n try {\n return (e.data.next_6_hours.details.air_temperature_min != null);\n } catch (ex) { }\n return false; //exclude item\n});\n\n//re-map the items to just an array of air_temperature\nvar Temperature_6h_min = filtered.map(e => {\n try {\n return e.data.next_6_hours.details.air_temperature_min;\n } catch (ex) {\n return null;\n }\n});\n\nmsg.payload = Temperature_6h_min;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":460,"wires":[["49198fa4.c79ce"]]},{"id":"38f7b58f.008a3a","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://10.0.0.115:4840","secpol":"None","secmode":"None","login":false}]
And this is how it looks when precented to my opcUA server:
And in the server (Wago PLC) i now can use the data as i wanted. Works perfect
If you or anyone else has any suggestions for improvement for the Node-red code I'd be grateful. Even though its working perfectly, maybe you know how to make it more compact, or more readable.
Thanks again!