Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error requesting data from WeatherBit: 429 #73

Open
Mariusthvdb opened this issue Aug 18, 2022 · 33 comments
Open

Error requesting data from WeatherBit: 429 #73

Mariusthvdb opened this issue Aug 18, 2022 · 33 comments

Comments

@Mariusthvdb
Copy link

I have given this some time (as in days), but Integration wont setup anymore:

Logger: homeassistant.config_entries
Source: config_entries.py:388 
First occurred: 22:47:15 (2 occurrences) 
Last logged: 22:47:24

Config entry 'Roosendaal' for weatherbit integration not ready yet: Error requesting data from WeatherBit: 429, message='', url=URL('https://api.weatherbit.io/v2.0/current?lat=xxx&lon=xxx&key=83eredacted88&lang=en&units=M'); Retrying in background

is this a know issue right now? Or did something go Amis in updating to HA 2022.8.6...

thanks!

@B-Kramer
Copy link

I just got the same issue after updating.

Logger: homeassistant.config_entries
Source: config_entries.py:1067
First occurred: 4:47:36 PM (1 occurrences)
Last logged: 4:47:36 PM

Config entry 'Country Life Acres' for weatherbit integration not ready yet: Error requesting data from WeatherBit: 429, message='', url=URL('https://api.weatherbit.io/v2.0/current?lat=38.65259474700931&lon=-90.48935672384688&key=f77974adbc6d4efd91ae6ae0b4f69a73&lang=en&units=M'); Retrying in background

@B-Kramer
Copy link

Followup: It's going over the request limit.

{"status_code":429,"status_message":"Your request count (585) is over the allowed limit of 500 per day - Upgrade your key, or retry after 129.85 minutes"}

@Mariusthvdb
Copy link
Author

Mariusthvdb commented Aug 19, 2022

right, I see that too now,
maybe cause by the fact its installed on several devices..?
how can we decrease that request count to fall under the 500 in that case?

wait, this seems the place:

Schermafbeelding 2022-08-20 om 01 00 35

Ive now increased from 5 to 10 minutes, which should be significant, lets see what happens next ;-)

@B-Kramer
Copy link

B-Kramer commented Aug 19, 2022 via email

@Mariusthvdb
Copy link
Author

haha we crossposted....

@briis
Copy link
Owner

briis commented Aug 20, 2022

There is nothing that has changed in the part of the code that handles the frequencies of updates for month. I have now done some extensive testing just to verify that this is running as expected, and it does.

When you start up HA and the Integration, it performs two calls to Weatherbit on startup: 1 for the current data and one for the Forecast, and then it follows the schedule. So if default values are selected it makes 1 call every 5 minutes for the current data and 1 call every 30 min for the forecast. That means 288 call for current data per day and 48 calls for the forecast per day. That is 336 calls per day, and way below the 500 that is on the Free plan.

The above number also indicates that if you run more than 1 location, then you MUST lower the frequency of updates to ensure you do not hit the 500 calls limit.

@Mariusthvdb
Copy link
Author

Thans Bjarne.

I am not running more than 1 location, but have ofc more than 1 device running HA.

Suppose that should not matter ( considering it is the Ha server doing the requests?)

@briis
Copy link
Owner

briis commented Aug 20, 2022

The above number (336 calls per day) is for each instance of Weatherbit running with 1 location setup. So if you use the Integration on two HA instances then you will get 2 x 336 calls per day.

@Mariusthvdb
Copy link
Author

Yeah. Understood.
Running 1 instance only though...

@B-Kramer
Copy link

I also only had one location being used...and still hit the limit. I've increased my polling times and not had problems since then.

@Mariusthvdb
Copy link
Author

Mariusthvdb commented Aug 21, 2022

well, Ive decreased the polling to 10 minutes, as explained above, and yet saw this:

2022-08-21 21:19:02.504 ERROR (MainThread) [custom_components.weatherbit] Error fetching weatherbit data: Error while retreiving data: Error requesting data from WeatherBit: 429, message='', url=URL('https://api.weatherbit.io/v2.0/current?lat=<lat>&lon=<lon>&key=<key>&lang=en&units=M&include=alerts')
2022-08-21 21:23:17.437 ERROR (MainThread) [custom_components.weatherbit] Error fetching weatherbit data: Error while retreiving data: Error requesting data from WeatherBit: 429, message='', url=URL('https://api.weatherbit.io/v2.0/forecast/daily?lat=<lat>&lon=<lon>&key=<key>&lang=en&units=M')

other than this, I have a few template sensors involving weatherbit sensors but don't think that would cause any extra polling?

and I have 1 card in HA frontend:

type: entities
header:
  type: picture
  image: /local/weather/weatherbit.png
  tap_action:
    action: url
    url_path: !secret weatherio_api_url
  hold_action:
    action: call-service
    service: homeassistant.reload_config_entry
    service_data:
      entry_id: b31782708171df0556b76c520ce103ed

but that url is only activated on a tap. Which didnt happen.

On holding the card above, I just saw all of my sensors disappear into the unknown..... tapping revealed the reason:

{"status_code":429,"status_message":"Your request count (536) is over the allowed limit of 500 per day - Upgrade your key, or retry after 215.26666666667 minutes"}

@B-Kramer
Copy link

I haven't had any more problems, my settings are 10 and 45 for each of the sliders.

@Mariusthvdb
Copy link
Author

wait, checking the integration again, it reveals that the slider has moved back to 5 minutes...

Schermafbeelding 2022-08-21 om 22 26 47

so this is odd in itself.

ofc, next to the fact that Bjarnes calculation for polling seems to no stick somehow, and my numbers are topping that in the default settings

@digitalwolf
Copy link

I've started getting this error the last couple of days. It appears that the free tier has been dropped to 50 calls per day.

@briis
Copy link
Owner

briis commented Oct 13, 2022

You are absolutely right - just checked the website. I made adjustments now to the minimum and maximum values of the updates, but honestly, this leaves this integration somewhat useless. I don't use it myself anymore, as I get my data elsewhere, and this does not encourage me to spend too much time on it.

Changes will be in 1.0.14, which I will put out soon.

I will make a post on the Community Forum also.

Thanks

@B-Kramer
Copy link

B-Kramer commented Oct 13, 2022 via email

@louispires
Copy link

Also looking at an alternative.
I have mine set to 30 Minutes and 120 Minutes for the Sensor and Forecast yet still go over the limit by 12PM...

Now to find another option...

@Bloodpack
Copy link

Bloodpack commented Oct 15, 2022

same here, since the last update i get to many requests

mine is set to 60 Minutes Sensor and 120 Minutes Forecast

{"status_code":429,"status_message":"Your request count (51) is over the allowed limit of 50 per day - Upgrade your key, or retry after 881.26666666667 minutes"}

@Mariusthvdb
Copy link
Author

but honestly, this leaves this integration somewhat useless. I don't use it myself anymore, as I get my data elsewhere, and this does not encourage me to spend too much time on it.

really sorry to hear Bjarne, I was an avid user, so thank you for your efforts nonetheless!

btw, what are you using for the sun intensity Weatherbit offered us? I cant seem to find a replacement for that

@briis
Copy link
Owner

briis commented Oct 15, 2022

The alternative for me, is:

  • Forecast: my Tempest Weather Station, which produces an AI based Forecast very locally. It seems pretty accurate, but does not contain all the data I can get from Weatherbit. But enough for my needs.
  • Current data: I use a mixture of a local Davis Vantage Vue weather station, the Tempest station for UV and Solar and a Davis AirLink for Air Quality.

With the above I am covered for my needs, and as all these devices are local (Except for Forecast), I can pull data as often as I want. 😁

@Bloodpack
Copy link

Bloodpack commented Oct 15, 2022

@B-Kramer @louispires

i use now openweathermap with Platinum Weather Card by @Makin-Things from HACS

Short Card

Platinum Weather Card

Long Card

Platinum Weather Card Large

in openweathermap config you have to use onecall_daily to get the forecast for 7 days

openweathermap_config

@greg520820
Copy link

"i use now openweathermap with Platinum Weather Card by @Makin-Things from HACS"

The free openweathermap api doesn't seem to allow "onecall_daily" selection. I get an invalid api key error, but the key works on hourly selection. Also openweathermap doesn't provide solar radiation levels on the free api.

@Bloodpack
Copy link

@greg520820

strange, i use onecall_daily and i use the free API

@greg520820
Copy link

greg520820 commented Oct 15, 2022 via email

@Bloodpack
Copy link

@greg520820

I have an very old API key possible they changed someting with new registrations

Here my Homeassistant versions

166587223084269303530221439039

@greg520820
Copy link

greg520820 commented Oct 17, 2022

It appears the sensor call from the integration is counting as 2 calls by Weatherbit. Setting the sensor call at 60 minutes and the forecast update at 240 minutes the call count increases by 2 each hour. I'm finding the call usage by using https://api.weatherbit.io/v2.0/subscription/usage?key="API_KEY". I even set the forecast interval at 720 minutes and checked the call count after 5 hours and it was 10 instead of the expected 5.

Only thing I could find in the api was this statement " include=minutely,alerts (optional: Include a 1 hour / minutely forecast , and severe weather alert in the response)*
*Counts as an extra request against quota."

I verified this is true by issuing a https://api.weatherbit.io/v2.0/current?lat=39.xxx&lon=--84.xxxx&key=xxxxxxx5258edb290xxxxd62&include=minutely and another without the "include=minutely" The first counted as 2 calls the last as 1 call. So maybe the integration is requesting the severe weather alert and that is counting as another call.

Is there a way to modify the code so it doesn't request the severe weather alert to see if this is the issue?

I would really like to get 1 hour sensor updates and 6 hour forecast interval, which should only be 28 calls, well within the 50 limit. I get severe weather alerts from another source (NWS).

Any help would be appreciated.

@briis
Copy link
Owner

briis commented Oct 18, 2022

Thanks @greg520820 for checking this. I was not aware that adding the alert would generate an extra call - here we go, maybe I should be more carefully in reading the docs 😁
Yes I could remove the automatic Weather Alert pull, it is a simple operation. But I would then have to add some extra config options for the people who want the Alerts, with the extra call this makes.
Let me see what I can do over the weekend.

@greg520820
Copy link

Thanks for looking at this. I've tried to find another source for similar information, but 16 days of daily forecasts with a full compliment of sensors, especially the solar radiation sensor, doesn't seem to exist. Your integration is great at pulling and presenting the data.

I will say that weather alert information is available from many sources, but being able to select if you wanted alert information would be ideal.

@greg520820
Copy link

Making the Alert pull selectable will certainly help with the 50 call limit. I tried to understand the code and the Alert pull seems to be hard-coded in the pyWeatherbitdata module? So I was not able to remove the Alert pull to checkout it out. According to Weatherbit most stations only update sensors every 15 to 30 minutes and forecasts every hour. So very short update intervals for the integration are often just pulling the same information from Weatherbit.

To evaluate the number of pulls I setup another free Weatherbit key using another email address. Not sure this would even be possible, but could the code be modified to allow two keys to be entered. Use one key for 50 pulls and then switch to second key? Or use the key until the "too many pulls error" was returned and then switch to other key. This would allow sensors, forecasts, and alerts to be retrieved with reasonably intervals.

@Mariusthvdb
Copy link
Author

if I would only use this for irradiance.... would that be possible at all, and stay within limits? Dont need the forecasts, or alerts. As Bjarne said, those can be had elsewhere. I havent found the irradiation however. and, ofc, that must be update at least hourly during the day

@greg520820
Copy link

With the current integration each call for irradiance level uses two calls, since sensors (which includes irradiance) and Alerts are combined in one call. This would allow for a sensor update interval of 60 minutes with forecasts unselected. This assumes you do not restart Home Assistant multiple times each day. Each time Home Assistant is restarted is would use two calls to initialize the sensors data.

If @briis is able to modify the integration to make Alerts optional/selectable then the sensor/irradiance interval could be set at 30 minutes and still stay within the 50 calls per day limit. The weather stations used by Weatherbit updates the sensor data every 15 to 30 minutes. So a 30 minute interval would work okay.

@briis
Copy link
Owner

briis commented Oct 22, 2022

I have just released 1.0.15. Here are the release notes for that:

BREAKING CHANGE This version now completely removes the Alerts from Weatherbit. As it turned out, even though I only did 1 REST call to Weatherbit to get Current, Forecast and Alert Data, the Alert data counted as an extra call. So by removing this, the Integration is a bit more usefull, after Weatherbit reduced the number of Free Calls per day from 500 down to 50.
Removing the Alert part is the best option, as this data is available in a few other specialized integrations like MeteoAlarm.

I have no plans of bringing that back as an option. Use one of the other Alert Integrations. I have not done a lot of testing, but it runs here at my site. Let me know how this works out for you all.

@Mariusthvdb
Copy link
Author

Magic. Thank you Bjarne! For your continued efforts!

Meanwhile I found the tomorrow.io integration to carry an irradiance sensor, but I am not sure it's the same as Weatherbit s info.

Just letting you know.

Again: appreciated!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants