forecastsolar: increase refresh interval to ~80 min (18 calls/day)#369
Merged
Conversation
Providers like fcsolar and solarprognose allow only 20 API calls per day. The previous setting shared TIME_BETWEEN_UTILITY_API_CALLS (15 min) with tariff APIs, which could exhaust the daily quota in ~5 hours. A dedicated TIME_BETWEEN_SOLAR_API_CALLS constant (24/18 * 60 * 60 = 4800 s, ~80 min) limits solar fetches to 18 per day, leaving 2 requests in reserve for restarts or transient errors. https://claude.ai/code/session_01Fje2KBxRp5jHNSsSvEFwUp
SolarPrognose allows only 20 API calls per day. Using 18 of them leaves 2 in reserve for restarts or errors (24h / 18 calls = ~80 min interval). The rate-limit constraint belongs to the provider class, not to core.py, so the interval is hardcoded in the super().__init__ call rather than relying on the generic TIME_BETWEEN_UTILITY_API_CALLS. https://claude.ai/code/session_01Fje2KBxRp5jHNSsSvEFwUp
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the SolarPrognose forecast provider’s refresh throttling so solar forecast API calls don’t consume limited daily quotas too quickly (distinct from the more frequent tariff/utility polling cadence used by core.py).
Changes:
- Enforces a provider-specific minimum refresh interval intended to cap SolarPrognose calls to ~18/day.
- Stops using the generic
min_time_between_api_callspassed fromcore.pyfor this provider (currently hardcoded in the provider constructor).
Comment on lines
54
to
70
| def __init__(self, pvinstallations, timezone, min_time_between_api_calls, | ||
| delay_evaluation_by_seconds, target_resolution=60) -> None: | ||
| """ Initialize the SolarPrognose class | ||
|
|
||
| Args: | ||
| pvinstallations: List of PV installation configurations | ||
| timezone: Timezone for forecast data | ||
| min_time_between_api_calls: Minimum seconds between API calls | ||
| delay_evaluation_by_seconds: Delay for API evaluation | ||
| target_resolution: Target resolution in minutes (15 or 60) | ||
| """ | ||
| # 18 calls/day leaves 2 in reserve out of the 20 allowed per day. | ||
| # Ignore the generic interval from core and enforce the provider limit here. | ||
| min_refresh = int(24 / 18 * 60 * 60) # ~80 min | ||
| super().__init__(pvinstallations, timezone, | ||
| min_time_between_api_calls, delay_evaluation_by_seconds, | ||
| min_refresh, delay_evaluation_by_seconds, | ||
| target_resolution=target_resolution, |
…er minimum - Replace float expression int(24/18*60*60) with integer floor division (24 * 60 * 60 // 18 = 4800 s exactly) to avoid IEEE 754 rounding risk. - Use max(min_time_between_api_calls, _provider_min) so the provider's rate-limit floor is enforced while larger values from the caller are still respected. https://claude.ai/code/session_01Fje2KBxRp5jHNSsSvEFwUp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Providers like fcsolar and solarprognose allow only 20 API calls per
day. The previous setting shared TIME_BETWEEN_UTILITY_API_CALLS (15 min)
with tariff APIs, which could exhaust the daily quota in ~5 hours.
A dedicated TIME_BETWEEN_SOLAR_API_CALLS constant (24/18 * 60 * 60 =
4800 s, ~80 min) limits solar fetches to 18 per day, leaving 2 requests
in reserve for restarts or transient errors.
https://claude.ai/code/session_01Fje2KBxRp5jHNSsSvEFwUp