I have openweathermap generating the current weather once a minute. That part works just fine. However, I would like to know if rain is in the forecast so that I can turn off my lawn sprinklers. I've tried creating a second OWM node and new API key for that node, and all I get is "invalid API key".
I tried changing the currently working node: "Current weather for.." to "5-Day forecast for..", but I can't find where in the JSON response I would find out if it's going to rain or not. And yes, I've read the API docs.
Any assistance would be greatly appreciated.
It appears that probability for precipitation is not included in the JSON API
So it looks like the best you can get is by hooking your setup to weather.main
and look for the text values such as "Rain"
, "Drizzle"
and "Snow"
. Furthermore, you can use msg.data
to page through the full API response, which gives the amount of precipitation already fallen in the last hour if needed
https://openweathermap.org/current#current_JSON
However, it appears the XML API does have some information about precipitation available, which in my opinion is odd that they didn't make those available in the JSON api as well.
I think I found it..
{
"dt":1567447200,
"main":{
"temp":20.16,
"temp_min":19.28,
"temp_max":20.16,
"pressure":1016.58,
"sea_level":1016.58,
"grnd_level":1005.97,
"humidity":84,
"temp_kf":0.88
},
"weather":[
{
"id":500,
"main":"Rain",
"description":"light rain",
"icon":"10d"
}
],
"clouds":{
"all":100
},
"wind":{
"speed":2.79,
"deg":170.433
},
"rain":{
"3h":0.5
},
"sys":{
"pod":"d"
},
"dt_txt":"2019-09-02 18:00:00"
},
This is the forecast for 5 hours from now, and it does show rain. Do you have any clue what this means?
"rain":{
"3h":0.5
}
Also, do you have any clue which object in an array of ten objects within an array of 40 objects should I be looking at? And there's two of these arrays of 40 objects of ten objects. I get dizzy trying to understand basic objects, so you can see why this has me puzzled.
9/2/2019, 9:33:57 AMnode: 5cd765d7.01a35c
msg : Object
object
topic: ""
payload: array[40]
[0 … 9]
0: object
1: object
2: object
3: object
4: object
5: object
6: object
7: object
8: object
9: object
[10 … 19]
[20 … 29]
[30 … 39]
_msgid: "136a2f4.0f761d1"
location: object
data: object
cod: "200"
message: 0.0111
cnt: 40
list: array[40]
city: object
title: "5 day Forecast"
Write the entire JSON output to a file and then open it in a text editor that can format/colour JSON.
Far easier to search for terms and see the over all structure.
This is the 5 day/3 hour forecast right? That means each of the items in the payload array contains 1 forecast every 3 hours for a period of 5 days. That's 8 a day, times 5 is 40 items total. Each of the objects has a timestamp for when it's going to be, I don't know from mind if the one nearest is shown first or last, but I can imagine in position 0. Each of those objects will have the same kind of formatting. Meaning you can use a JSONAta to get out what you want. I'm bad at writing those, but I know others on this forum are genius at that.
I think this depends on what the API docs say for it. Could be probability, like 50% chance for rain... can be 0.5mm of rainfall. Look it up in the OWM api docs, that's all I can advise. I use a completely different API for my own forecasting needs, so I'm not able to help you there without looking up those things in the same place myself too.
Yes, from the 5 day/3 hour forecast. But there is no current weather, (but a second node with "Current Weather" selected does work with the same API key).
The objects are not formatted the same. Object 0 in array 0 contains no rain object. The rest do.
9/2/2019, 10:05:10 AMnode: d39452b1.78f4a
msg.payload : array[40]
array[40]
[0 … 9]
0: object
dt: 1567436400
main: object
weather: array[1]
clouds: object
wind: object
sys: object
dt_txt: "2019-09-02 15:00:00"
1: object
dt: 1567447200
main: object
weather: array[1]
clouds: object
wind: object
rain: object
3h: 0.5
sys: object
dt_txt: "2019-09-02 18:00:00"
2: object
dt: 1567458000
main: object
weather: array[1]
clouds: object
wind: object
rain: object
3h: 2.188
sys: object
dt_txt: "2019-09-02 21:00:00"
3: object
dt: 1567468800
main: object
weather: array[1]
clouds: object
wind: object
rain: object
3h: 10.687
sys: object
dt_txt: "2019-09-03 00:00:00"
I was guessing that the rain object shows the accumulated rain over three hours. But if this were so, I should have a boat handy in the third object.