The end of Darksky?

I've just finished installed my irrigation system and i ask to myself : "Why i don't do a nodered flow to control it with rain prediction?". I ended up looking for Darksky node and see that it's no longer working... so sad...
What about met.no? I can't find a node for that...
Any alternative? I just need rain forecast...

But you do have a node: http request, it is beautiful.

Sample flow:

[{"id":"a8f0f669.71c04","type":"inject","z":"4ac4ee9b.f58ab8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":132,"y":288,"wires":[["a2c1eecd.5542f8"]]},{"id":"a2c1eecd.5542f8","type":"http request","z":"4ac4ee9b.f58ab8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://api.met.no/weatherapi/locationforecast/1.9/?lat=60.10&lon=9.58","tls":"","persist":false,"proxy":"","authType":"","x":276,"y":288,"wires":[["18c4d05e.5e7cf8"]]},{"id":"ff2201ca.ac7f2","type":"debug","z":"4ac4ee9b.f58ab8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":574,"y":288,"wires":[]},{"id":"18c4d05e.5e7cf8","type":"xml","z":"4ac4ee9b.f58ab8","name":"","property":"payload","attr":"","chr":"","x":422,"y":288,"wires":[["ff2201ca.ac7f2"]]}]

It uses this schema
https://api.met.no/weatherapi/locationforecast/1.9/schema

Thank you mate!
Forgive me, i'm pretty noob... Where can i find info about rain forecast for the next day? There are some many data :smiley:

There is a flow available

https://flows.nodered.org/flow/affa4bd5194a25019081d2ec8191fa48

Make sure to enable the debug node.

Thank you again! Looks like the actual weather... Am i wrong? Can i retreive the forecast for tomorrow?

Sure you have to modify the flow to your liking.

Ehm... ok :smiley:
I found where to put my location, but i can't find where to put the desired time of forecast...

Try this flow:

[{"id":"b37cb5f7.40afc8","type":"http request","z":"cdcdc7ba.8d316","name":"api.met.no","method":"GET","ret":"obj","paytoqs":false,"url":"https://api.met.no/weatherapi/locationforecast/1.9/.json?lat={{{lat}}}&lon={{{lon}}}","tls":"","persist":false,"proxy":"","authType":"","x":1143,"y":912,"wires":[["8bb1051.6f58478"]],"l":false},{"id":"f5816368.5f60e8","type":"debug","z":"cdcdc7ba.8d316","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1274,"y":912,"wires":[]},{"id":"465a08b7.28dab","type":"inject","z":"cdcdc7ba.8d316","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":756,"y":912,"wires":[["d39f0d5b.ccc7d8"]]},{"id":"5aa730bd.fe1db","type":"change","z":"cdcdc7ba.8d316","name":"location","rules":[{"t":"set","p":"lat","pt":"msg","to":"53.4","tot":"str"},{"t":"set","p":"lon","pt":"msg","to":"4.46","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1044,"y":912,"wires":[["b37cb5f7.40afc8"]]},{"id":"d39f0d5b.ccc7d8","type":"function","z":"cdcdc7ba.8d316","name":"tomorrow","func":"\nlet day = new Date();\nlet t = new Date(day);\nt.setDate(day.getDate() + 1);\nt.setHours(11) // 11:00 local will be converted to UTC\nt.setMinutes(0);\nt.setSeconds(0);\n\nreturn {tomorrow:t.toISOString().split('.')[0]+\"Z\"};","outputs":1,"noerr":0,"x":900,"y":912,"wires":[["5aa730bd.fe1db"]]},{"id":"8bb1051.6f58478","type":"change","z":"cdcdc7ba.8d316","name":"get data","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"date\":$$.tomorrow,\t    \"data\":**.time[from=$$.tomorrow].location\t}","tot":"jsonata"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"responseUrl","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1191,"y":912,"wires":[["f5816368.5f60e8"]],"l":false}]

The forecast data is returned per hour, in the "tomorrow" function node, I have set it to 11:00, which is 09:00UTC, adjust to your liking. It will return an object with an array of 3 arrays, in the 2rd one you will find the precipitation.

@bakman2 - v2 (in beta) gives you a json response... https://api.met.no/weatherapi/locationforecast/2.0/documentation#!/data/get

1 Like

I did see json on their api but not for all endpoints, nice.

In addition, 1.9 supports json too, but you’ve to specifically request it. 2.0 defaults to json, and you’ve to specifically request xml if you’re looking for that. While 2.0 is beta, and not yet having the format made strict, I prefer the json output from it. If you use 2.0, make sure you set a user-agent otherwise it will fail.
I keep hopping in and out of illness, but I’m working on a met.no node that allows to pick between the versions and gives a standardised output, as well as request specific parts like forecast for a specific day. There’s also differences in which country the location requested is at, for Norway it returns far more data than for other countries, and speaking from experience that really doesn’t make xml parsing any more fun.

4 Likes

Thank you for your help! I'm gonna test it!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.