iobroker-community-adapters / ioBroker.accuweather

Accuweather forecast
MIT License
6 stars 9 forks source link

Improve handling of limited api calls #273

Open mcm1957 opened 1 year ago

mcm1957 commented 1 year ago

The adapter currently makes app. 24+ 4 +2 = 30 api calls per day. Those calls are limited to 50 per day. In addition the adapter makes 3 calls during startup.

a) If the adapter starts more than 6 time, the limit is hit causing errors b) If the limit is hit, the adapter crashes and restarts crashing again due to exceeded limit

The adapter should NOT make api calls during startup if the states already contain valid data which is not outdated. Might require to add additonal "last retrieved states" but might be controlled by timestamps of states too.

see https://forum.iobroker.net/topic/67782/accuweather-st%C3%BCrzt-permanent-ab

xdaamg commented 8 months ago

Last days i got several error messages from this api like this: ERROR: {"Code":"ServiceUnavailable","Message":"The allowed number of requests has been exceeded."

It would be no problem, if users could change those fixed api-calls 'every hour' or 'every six hours' in adapter settings to other intervalls. Or just a setting to switch off those automatic refreshes. Every time i need an update, i would trigger one of the datapoints: accuweather.0.updateDaily or set an schedule with javascript.

This would reduce number of api-calls.

JayVee2 commented 7 months ago

I also start geetting these messages while not touching the system:

accuweather.0 2024-02-22 05:05:18.494 error Error: Forecast cannot be retrieved. ERROR: {"Code":"ServiceUnavailable","Message":"The allowed number of requests has been exceeded.","Reference":"/currentconditions/v1/xyz?apikey=xyz&language=de&metric=true&details=true"}
accuweather.0 2024-02-22 05:00:24.162 error Error: Forecast cannot be retrieved. ERROR: {"Code":"ServiceUnavailable","Message":"The allowed number of requests has been exceeded.","Reference":"/currentconditions/v1/xyz?apikey=xyz&language=de&metric=true&details=true"}

Any ideas?

xdaamg commented 3 months ago

"Current conditions" sollte nur stündlich abgefragt werden, das Protokoll sagt aber, dass es zwei fehlgeschlagene API-Calls gab und das wiederholt sich seitdem jede Stunde.

2024-06-21 08:00:28.232 - error: accuweather.0 (1691) Error: Forecast cannot be retrieved. ERROR: {"Code":"ServiceUnavailable","Message":"The allowed number of requests has been exceeded.","Reference":"/currentconditions/v1/...

2024-06-21 08:05:21.450 - error: accuweather.0 (1691) Error: Forecast cannot be retrieved. ERROR: {"Code":"ServiceUnavailable","Message":"The allowed number of requests has been exceeded.","Reference":"/currentconditions/v1/...

Ich habe im Fork eine kleine Änderung vorgenommen, seitdem wird wieder stündlich einmal abgefragt. https://github.com/xdaamg/ioBroker.accuweather/commit/06999fe2fe88f2939647366d1235f8bea27030e2

mcm1957 commented 3 months ago

Danke, schaus mir am WE an. Nach erstem Blick auf change dürftes du recht haben - <=5 kann zur Minute 0 und zur MInute 5 triggern. Ich glaub 3 Zeilen drunter gibts noch ein <= 5 ... muss mir das auch ansehn

mcm1957 commented 3 months ago

partly fixed with release 1.5.0

THANKS to @xdaamg for investigating an fixing the issue.

In general adapter should check after restart if data has to be refreshed or is already valid.