mschlenstedt / LoxBerry-Plugin-Weather4Lox

A LoxBerry Plugin: http://plugins.loxberry.de/plugin/weather4lox/
Apache License 2.0
10 stars 10 forks source link

Feature Request - Different fetch interval for current and forecast #88

Closed mr-manuel closed 1 year ago

mr-manuel commented 1 year ago

Would it be possible to fetch the current weather data with a different time interval as the forecast data?

Reason for this is, that I want to fetch the current data every minute from my own weather station over Weatherflow, but I don't need an update every minute for the forecasts from Visual Crossing. This would also exceed the free API calls.

mr-manuel commented 1 year ago

This should work, but it's not so a nice solution, since we need two fetch files that are linked in different cron folders and they contain the same lines.

https://github.com/mr-manuel/LoxBerry-Plugin-Weather4Lox/compare/master...mr-manuel:LoxBerry-Plugin-Weather4Lox:different-fetch-intervals

Do you have a better idea how to handle that?

mschlenstedt commented 1 year ago

Well, to be honest I don't know if we should implement this - it is a really special usecase not much users will need. But we need additional settings in the config, which may confuse most of the users.

Two fetch files is no option. If we will implement this, we have to think about how to optimize number of used API calls with onecall apis. E. g. if you fetch current weather every minute and forecasts every 3 minutes, you need only one call for both at the 3. minute...

mr-manuel commented 1 year ago

Thanks for your answer. I had an idea now. I can create a cronjob_helper.pl file that is called every minute. The file then executes the fetch.pl considering the settings, how often which data should be fetched, by passing --current, --daily and/or hourly.

The GUI should be intuitive.

grafik

mschlenstedt commented 1 year ago

So the second cronjob is active only if I use the alternative weatherservices for forecast? If I deactivate it, it will fetch only with the original cronjob and the second one is deactivated?

mr-manuel commented 1 year ago

If Fetch Weather Data is enabled, one cronjob cronjob.pl (which runs every minute) gets enabled. The cronjob then checks which data should be fetched at the current minute. I uploaded already the changes in my branch, so maybe its easier to understand. The cronjob.pl is not finished yet.

When I understood it correctly, the Alternative Weather Services also before my modifications were only fetched, if the Fetch Weather Data was on?

mr-manuel commented 1 year ago

Now I finished it. The last question I have is where the cronjobs get deleted in the update process of the plugin. I found those lines https://github.com/mschlenstedt/LoxBerry-Plugin-Weather4Lox/blob/c3e1c45364e57567397b9d7be5aec3f2aec264cb/postupgrade.sh#L26-L47 to recreate them, but nowhere where they are deleted. Are they automatically deleted by LoxBerry during a plugin update?

christianTF commented 1 year ago

Cronjobs named as the plugin (PLUGINNAME) in the /cron/cron.xxx folders are deleted on update and uninstall by LoxBerry.

mschlenstedt commented 1 year ago

Make a Pulltequest please. We will then have a look at the code. This should be easier to understand 😀

mr-manuel commented 1 year ago

Could you first check and close my open pull request?

mschlenstedt commented 1 year ago

Done

mr-manuel commented 1 year ago

Were you able to review the pull request?

mr-manuel commented 1 year ago

Feature was merged

mr-manuel commented 1 year ago

Cronjobs named as the plugin (PLUGINNAME) in the /cron/cron.xxx folders are deleted on update and uninstall by LoxBerry.

This does not seem to work anymore with LoxBerry V3. If I upgrade or uninstall the plugin the cronjobs are not deleted anymore. Is this a bug or a feature?