Skip to content

forecastsolar: increase refresh interval to ~80 min (18 calls/day)#369

Merged
MaStr merged 3 commits into
mainfrom
claude/magical-euler-KOn9o
May 27, 2026
Merged

forecastsolar: increase refresh interval to ~80 min (18 calls/day)#369
MaStr merged 3 commits into
mainfrom
claude/magical-euler-KOn9o

Conversation

@MaStr
Copy link
Copy Markdown
Owner

@MaStr MaStr commented May 27, 2026

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

claude added 2 commits May 26, 2026 19:45
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
Copilot AI review requested due to automatic review settings May 27, 2026 04:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_calls passed from core.py for this provider (currently hardcoded in the provider constructor).

Comment thread src/batcontrol/forecastsolar/solarprognose.py Outdated
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,
Comment thread src/batcontrol/forecastsolar/solarprognose.py Outdated
Comment thread src/batcontrol/forecastsolar/solarprognose.py Outdated
…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
@MaStr MaStr merged commit 0cbf194 into main May 27, 2026
13 checks passed
@MaStr MaStr deleted the claude/magical-euler-KOn9o branch May 27, 2026 05:02
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

Successfully merging this pull request may close these issues.

3 participants