Newbie question: openweather 5 day prediction filter (min temp value)

I'm a little bit lost here, I try to filter the lowest temp from the 5 day weather forecast to close some water valves if for example temp_min is below -5°..
Hereunder a small part (3 of 40) of the msg output from the 5 day weather forecast from openWeather API.

I just want to return all days when the (temp_min) is lower than -5° as a result. I was busy all day trying to get this result but I'm completely lost :-(.

Some insights would be appreciated.
I understand the basics of For loops and If then statements but it's really hard for me to apply this on real examples.


Have a look the javascript Array.filter() method.

Have a play with that and see if you can work it out.

Hello Colin, thanks for your response and your help. I've made progress :slight_smile:
If I do this, It get the expected result. It seems that my first array was incomplete also btw..

const mintemps = [

const result = mintemps.filter(mintemps => mintemps.main.temp_min <7);


Array [Object { dt: 1606500000, main: Object { temp: 7.15, feels_like: 3.96, temp_min: 6.85, temp_max: 7.15, pressure: 1018 } }, Object { dt: 1606510800, main: Object { temp: 6.64, feels_like: 3.61, temp_min: 6.53, temp_max: 6.64, pressure: 1019 } }]

You can also do this in the change node using JSONata expression.

[{"id":"b0987c18.4dcc6","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[][main.temp_min < 7]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":2120,"wires":[["e8309938.fb1628"]]},{"id":"d8f3269b.a43d9","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"dt\":1606489200,\"main\":{\"temp\":8.44,\"feels_like\":5.83,\"temp_min\":8.44,\"temp_max\":8.64,\"pressure\":1018}},{\"dt\":1606500000,\"main\":{\"temp\":7.15,\"feels_like\":3.96,\"temp_min\":6.85,\"temp_max\":7.15,\"pressure\":1018}},{\"dt\":1606510800,\"main\":{\"temp\":6.64,\"feels_like\":3.61,\"temp_min\":6.53,\"temp_max\":6.64,\"pressure\":1019}}]","payloadType":"json","x":130,"y":2120,"wires":[["b0987c18.4dcc6","e8309938.fb1628"]]},{"id":"e8309938.fb1628","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":2040,"wires":[]}]

this will return all array items where temp_min is less than 7.

If you wanted just the timestamps back then if you then use .map() on the filtered result you can return just an array of timestamps.

I'll try that to Cid, thank you.

I'll have a look at .map () too. thank you (again :slight_smile:

If you just want the timestamps the Jsonata expression would be payload[][main.temp_min < 7].dt

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