# The end of Darksky?

**URL:** <https://discourse.nodered.org/t/the-end-of-darksky/24003>\
**Category:** General\
**Created:** [31 March 2020 22:59 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003 "2020-03-31T22:59:59Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![H3rian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3rian/32/20645_2.png) [@H3rian](https://discourse.nodered.org/u/H3rian)\
**Post date:** [25 April 2020 15:58 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/21 "2020-04-25T15:58:27Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 April 2020 16:09 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/22 "2020-04-25T16:09:41Z")

</div>

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

Sample flow:

```auto
[{"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](https://api.met.no/weatherapi/locationforecast/1.9/schema)

---

<div class="post-metadata">

**Author:** ![H3rian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3rian/32/20645_2.png) [@H3rian](https://discourse.nodered.org/u/H3rian)\
**Post date:** [25 April 2020 16:16 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/23 "2020-04-25T16:16:33Z")

</div>

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 😃

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 April 2020 16:32 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/24 "2020-04-25T16:32:24Z")

</div>

There is a flow available

[https://flows.nodered.org/flow/affa4bd5194a25019081d2ec8191fa48](https://flows.nodered.org/flow/affa4bd5194a25019081d2ec8191fa48)

Make sure to enable the debug node.

---

<div class="post-metadata">

**Author:** ![H3rian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3rian/32/20645_2.png) [@H3rian](https://discourse.nodered.org/u/H3rian)\
**Post date:** [25 April 2020 16:37 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/25 "2020-04-25T16:37:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 April 2020 16:45 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/26 "2020-04-25T16:45:01Z")

</div>

Sure you have to modify the flow to your liking.

---

<div class="post-metadata">

**Author:** ![H3rian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3rian/32/20645_2.png) [@H3rian](https://discourse.nodered.org/u/H3rian)\
**Post date:** [25 April 2020 16:48 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/27 "2020-04-25T16:48:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 April 2020 17:31 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/28 "2020-04-25T17:31:48Z")

</div>

Try this flow:

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 April 2020 18:09 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/29 "2020-04-25T18:09:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 April 2020 18:38 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/30 "2020-04-25T18:38:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [25 April 2020 20:37 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/31 "2020-04-25T20:37:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![H3rian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3rian/32/20645_2.png) [@H3rian](https://discourse.nodered.org/u/H3rian)\
**Post date:** [3 May 2020 10:29 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/32 "2020-05-03T10:29:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [2 July 2020 10:29 UTC](https://discourse.nodered.org/t/the-end-of-darksky/24003/33 "2020-07-02T10:29:42Z")

</div>

Closed on 2 July 2020 10:29 UTC

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

[Previous page](https://discourse.nodered.org/t/the-end-of-darksky/24003.md?page=1)
