-
-
Notifications
You must be signed in to change notification settings - Fork 94
Forecast.solar timezone fix #2949
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
Conversation
There was a problem hiding this 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 fixes timezone handling issues in the forecast.solar integration by requesting UTC timestamps from the API and removing local-to-UTC timezone conversion logic.
Key Changes:
- Added
?time=utcquery parameter to forecast.solar API URLs to receive timestamps in UTC - Removed custom
TIME_FORMAT_FORECAST_SOLARconstant and timezone offset calculations - Updated version from v8.27.25 to v8.27.26
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/predbat/config.py | Removed unused TIME_FORMAT_FORECAST_SOLAR constant |
| apps/predbat/solcast.py | Updated API URLs with ?time=utc parameter, switched to TIME_FORMAT for parsing, and removed timezone offset conversion logic |
| apps/predbat/predbat.py | Version bump to v8.27.26 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| forecast_watt_data = {} | ||
| for period_end in watts: | ||
| period_end_stamp = datetime.strptime(period_end, TIME_FORMAT_FORECAST_SOLAR) | ||
| period_end_stamp = datetime.strptime(period_end, TIME_FORMAT) |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential datetime parsing issue: TIME_FORMAT is defined as "%Y-%m-%dT%H:%M:%S%z" which expects timezone offset in +HHMM or +HH:MM format. However, when the forecast.solar API returns UTC timestamps (with ?time=utc parameter), they typically use either:
- ISO 8601 format with 'Z' suffix (e.g.,
"2024-01-15T12:00:00Z"), or - Space-separated format without timezone (e.g.,
"2024-01-15 12:00:00")
Python's %z directive doesn't recognize the 'Z' literal. If the API returns format (1), you'd need to replace 'Z' with '+00:00' before parsing. If it returns format (2), the 'T' separator won't match.
Please verify the actual format returned by the API with ?time=utc and adjust the parsing accordingly.
| continue | ||
|
|
||
| current_time = info.get("time", None) | ||
| current_time_stamp = datetime.strptime(current_time, TIME_FORMAT) |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same parsing concern as line 288: verify that the info.get("time") value from the forecast.solar API response matches the TIME_FORMAT pattern, especially regarding timezone representation.
#2911