Thanks again both of you @TotallyInformation and @E1cid
Both ways works fine. I also managed to publish this array to my OPCUA server, which is a Wago PLC.
If you have any improvement to this I am thankful
I also want to use a variable to trigger the http request. And i also want to set up a Gauge to display ex array[17]. Any ideas how to do this?
And I was thinking it would be smart to use a for loop to get the data info the array. I tried like this, but i only get 1 datapoint.
And is there a way to get rid of all this red text showing up in de debug window?
Thanks in advance
And here is the code so far:
[{"id":"8d1d8f1c.dd3a4","type":"tab","label":"Værdata","disabled":false,"info":""},{"id":"c5c068bb.040ca8","type":"debug","z":"8d1d8f1c.dd3a4","name":"Data fra api.met.no","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":260,"wires":[]},{"id":"3d1ac866.952508","type":"OpcUa-Client","z":"8d1d8f1c.dd3a4","endpoint":"d66a982f.e2c078","action":"write","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"","securitymode":"None","securitypolicy":"None","name":"","x":1240,"y":320,"wires":[[]]},{"id":"344fd399.f5ce6c","type":"debug","z":"8d1d8f1c.dd3a4","name":"Temperatur Array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":260,"wires":[]},{"id":"b5399af0.72ebd8","type":"http request","z":"8d1d8f1c.dd3a4","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.met.no/weatherapi/locationforecast/2.0/complete?altitude=70&lat=59.023441&lon=6.041370","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":320,"wires":[["86f7bed4.dec77","c5c068bb.040ca8","c7c09a0b.fc9918"]]},{"id":"86f7bed4.dec77","type":"function","z":"8d1d8f1c.dd3a4","name":"Temperatur","func":"const times = msg.payload.properties.timeseries\n\n\nconst rAirtemps = [\ntimes[0].data.instant.details.air_temperature,\ntimes[1].data.instant.details.air_temperature,\ntimes[2].data.instant.details.air_temperature,\ntimes[3].data.instant.details.air_temperature,\ntimes[4].data.instant.details.air_temperature,\ntimes[5].data.instant.details.air_temperature,\ntimes[6].data.instant.details.air_temperature,\ntimes[7].data.instant.details.air_temperature,\ntimes[8].data.instant.details.air_temperature,\ntimes[9].data.instant.details.air_temperature,\ntimes[10].data.instant.details.air_temperature,\ntimes[11].data.instant.details.air_temperature,\ntimes[12].data.instant.details.air_temperature,\ntimes[13].data.instant.details.air_temperature,\ntimes[14].data.instant.details.air_temperature,\ntimes[15].data.instant.details.air_temperature,\ntimes[16].data.instant.details.air_temperature,\ntimes[17].data.instant.details.air_temperature,\ntimes[18].data.instant.details.air_temperature,\ntimes[19].data.instant.details.air_temperature,\ntimes[20].data.instant.details.air_temperature,\ntimes[21].data.instant.details.air_temperature,\ntimes[22].data.instant.details.air_temperature,\ntimes[23].data.instant.details.air_temperature,\ntimes[24].data.instant.details.air_temperature,\ntimes[25].data.instant.details.air_temperature,\ntimes[26].data.instant.details.air_temperature,\ntimes[27].data.instant.details.air_temperature,\ntimes[28].data.instant.details.air_temperature,\ntimes[29].data.instant.details.air_temperature,\ntimes[30].data.instant.details.air_temperature,\ntimes[31].data.instant.details.air_temperature,\ntimes[32].data.instant.details.air_temperature,\ntimes[33].data.instant.details.air_temperature,\ntimes[34].data.instant.details.air_temperature,\ntimes[35].data.instant.details.air_temperature,\ntimes[36].data.instant.details.air_temperature,\ntimes[37].data.instant.details.air_temperature,\ntimes[38].data.instant.details.air_temperature,\ntimes[39].data.instant.details.air_temperature,\ntimes[40].data.instant.details.air_temperature,\ntimes[41].data.instant.details.air_temperature,\ntimes[42].data.instant.details.air_temperature,\ntimes[43].data.instant.details.air_temperature,\ntimes[44].data.instant.details.air_temperature,\ntimes[45].data.instant.details.air_temperature,\ntimes[46].data.instant.details.air_temperature,\ntimes[47].data.instant.details.air_temperature,\ntimes[48].data.instant.details.air_temperature,\ntimes[49].data.instant.details.air_temperature,\ntimes[50].data.instant.details.air_temperature,\n\n]\n\nmsg.payload = rAirtemps\nreturn msg\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":320,"wires":[["e23bffa4.09488","344fd399.f5ce6c"]]},{"id":"e23bffa4.09488","type":"OpcUa-Item","z":"8d1d8f1c.dd3a4","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rAirtemps","datatype":"Float Array","value":"","name":"Temperatur OPC ","x":970,"y":320,"wires":[["3d1ac866.952508"]]},{"id":"c17d1b4b.a153a8","type":"inject","z":"8d1d8f1c.dd3a4","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":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":320,"wires":[["b5399af0.72ebd8"]]},{"id":"c7c09a0b.fc9918","type":"function","z":"8d1d8f1c.dd3a4","name":"Nedbør","func":"const times = msg.payload.properties.timeseries\n\n\nconst rPrecipitation = [\ntimes[0].data.next_1_hours.details.precipitation_amount,\ntimes[1].data.next_1_hours.details.precipitation_amount,\ntimes[2].data.next_1_hours.details.precipitation_amount,\ntimes[3].data.next_1_hours.details.precipitation_amount,\ntimes[4].data.next_1_hours.details.precipitation_amount,\ntimes[5].data.next_1_hours.details.precipitation_amount,\ntimes[6].data.next_1_hours.details.precipitation_amount,\ntimes[7].data.next_1_hours.details.precipitation_amount,\ntimes[8].data.next_1_hours.details.precipitation_amount,\ntimes[9].data.next_1_hours.details.precipitation_amount,\ntimes[10].data.next_1_hours.details.precipitation_amount,\ntimes[11].data.next_1_hours.details.precipitation_amount,\ntimes[12].data.next_1_hours.details.precipitation_amount,\ntimes[13].data.next_1_hours.details.precipitation_amount,\ntimes[14].data.next_1_hours.details.precipitation_amount,\ntimes[15].data.next_1_hours.details.precipitation_amount,\ntimes[16].data.next_1_hours.details.precipitation_amount,\ntimes[17].data.next_1_hours.details.precipitation_amount,\ntimes[18].data.next_1_hours.details.precipitation_amount,\ntimes[19].data.next_1_hours.details.precipitation_amount,\ntimes[20].data.next_1_hours.details.precipitation_amount,\ntimes[21].data.next_1_hours.details.precipitation_amount,\ntimes[22].data.next_1_hours.details.precipitation_amount,\ntimes[23].data.next_1_hours.details.precipitation_amount,\ntimes[24].data.next_1_hours.details.precipitation_amount,\ntimes[25].data.next_1_hours.details.precipitation_amount,\ntimes[26].data.next_1_hours.details.precipitation_amount,\ntimes[27].data.next_1_hours.details.precipitation_amount,\ntimes[28].data.next_1_hours.details.precipitation_amount,\ntimes[29].data.next_1_hours.details.precipitation_amount,\ntimes[30].data.next_1_hours.details.precipitation_amount,\ntimes[31].data.next_1_hours.details.precipitation_amount,\ntimes[32].data.next_1_hours.details.precipitation_amount,\ntimes[33].data.next_1_hours.details.precipitation_amount,\ntimes[34].data.next_1_hours.details.precipitation_amount,\ntimes[35].data.next_1_hours.details.precipitation_amount,\ntimes[36].data.next_1_hours.details.precipitation_amount,\ntimes[37].data.next_1_hours.details.precipitation_amount,\ntimes[38].data.next_1_hours.details.precipitation_amount,\ntimes[39].data.next_1_hours.details.precipitation_amount,\ntimes[40].data.next_1_hours.details.precipitation_amount,\ntimes[41].data.next_1_hours.details.precipitation_amount,\ntimes[42].data.next_1_hours.details.precipitation_amount,\ntimes[43].data.next_1_hours.details.precipitation_amount,\ntimes[44].data.next_1_hours.details.precipitation_amount,\ntimes[45].data.next_1_hours.details.precipitation_amount,\ntimes[46].data.next_1_hours.details.precipitation_amount,\ntimes[47].data.next_1_hours.details.precipitation_amount,\ntimes[48].data.next_1_hours.details.precipitation_amount,\ntimes[49].data.next_1_hours.details.precipitation_amount,\ntimes[50].data.next_1_hours.details.precipitation_amount,\n]\n\nmsg.payload = rPrecipitation\nreturn msg\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":380,"wires":[["ca3d45e4.b20d78","9841c0f.05a664"]]},{"id":"ca3d45e4.b20d78","type":"OpcUa-Item","z":"8d1d8f1c.dd3a4","item":"ns=4;s=|var|WAGO 750-8212 PFC200 G2 2ETH RS.Application.gvl_OpcUA.rPrecipitation","datatype":"Float Array","value":"","name":"Nedbør OPC","x":950,"y":380,"wires":[["3d1ac866.952508"]]},{"id":"9841c0f.05a664","type":"debug","z":"8d1d8f1c.dd3a4","name":"Nedbør Array","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":440,"wires":[]},{"id":"d66a982f.e2c078","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://10.0.0.15:4840","secpol":"None","secmode":"None","login":false}]