c5te1n / node-red-contrib-dwd-local-weather

Node Red node to retrieve local weather forecast from DWD (Germany)
Apache License 2.0
13 stars 11 forks source link

Set update timeout slightly below 1 hour #17

Closed holgerpieta closed 3 years ago

holgerpieta commented 4 years ago

From #10 I see the reasons for the 1 hour timeout before pulling a new forecast file. However, if someone (like me) runs a flow once per hour and that flow does a lot of variable time stuff (like pulling data from another server) before actually coming to the DWD node, time between two calls may be anything, for example, between 3595 seconds and 3605 seconds. If the last call was late, but the new one early, it may be below 3600 seconds and no update is pulled. Next time the last call might have been early and the new one late, it's above 3600 seconds and an update is pulled. Long story short: Probably a lot of people use "once per hour" and in this case forecast update is unstable, sometimes it happens, sometimes not. Solution: Set MOSMIX_MAXAGE to 55 minutes for example. Then even highly variable "once per hour" flows will always get a new file. Of course, if someone runs a flow every 55 minutes, he'll get the same problem again. But I think the number of "once every 55 minutes" flows is very low compared to "once per hour".

ei23com commented 4 years ago

As far as i know MOSMIX L files are updated only 4 times a day. So if you pull once per hour, you pull allready 6 times per the same file again. If the traffic on dwd gets too high, they may have to limit or even shut down there service...

holgerpieta commented 4 years ago

You're totally right and I wouldn't mind at all if the node caches the results for 6 hours and updates only around the time new results are uploaded to the server. I'm merely suggesting a simple change that improves the current situation slightly, making it a bit more stable without solving the 6 hour problem.

c5te1n commented 3 years ago

I'll reduce the max age in the next version slightly, so that if a flow triggers the node every 60 minutes we make sure we get an updated file at that point in time. We'll still download the file more often than needed, but make sure we don't work with a version that is just not outdated in those cases.