Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0.0",
"last_updated": "2026-03-30",
"last_updated": "2026-04-02",
"plugins": [
{
"id": "hello-world",
Expand Down Expand Up @@ -59,10 +59,10 @@
"repo": "https://github.com/ChuckBuilds/ledmatrix-plugins",
"branch": "main",
"plugin_path": "plugins/ledmatrix-weather",
"latest_version": "2.2.0",
"latest_version": "2.2.2",
"stars": 0,
"downloads": 0,
"last_updated": "2026-03-30",
"last_updated": "2026-04-02",
"verified": true,
"screenshot": ""
},
Expand Down
8 changes: 8 additions & 0 deletions plugins/ledmatrix-weather/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ def update(self) -> None:
if self.consecutive_errors >= self.max_consecutive_errors:
if current_time - self.last_error_time < self.error_backoff_time:
self.logger.debug(f"In error backoff period, retrying in {self.error_backoff_time - (current_time - self.last_error_time):.0f}s")
# Still reprocess forecast so past hours drop off the display
if self.forecast_data:
self._process_forecast_data(self.forecast_data)
return
else:
# Reset error count after backoff
Expand Down Expand Up @@ -361,6 +364,11 @@ def update(self) -> None:
self.logger.error(f"Weather API disabled for {self.error_backoff_time} seconds due to repeated failures")
self.last_error_log_time = current_time

# Re-filter existing forecast data so past hours drop off the
# hourly display even when API calls are failing.
if self.forecast_data:
self._process_forecast_data(self.forecast_data)

def _update_radar(self) -> None:
"""Refresh radar data in the update loop so display() never blocks on HTTP."""
if not self.show_radar:
Expand Down
2 changes: 1 addition & 1 deletion plugins/ledmatrix-weather/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "ledmatrix-weather",
"name": "Weather Display",
"version": "2.2.0",
"version": "2.2.2",
"author": "ChuckBuilds",
"class_name": "WeatherPlugin",
"description": "Comprehensive weather display with current conditions, hourly forecast, daily forecast, almanac (sunrise/sunset, moon phase), precipitation radar, weather alerts, UV index, wind direction, and weather icons. Powered by OpenWeatherMap + RainViewer APIs.",
Expand Down
9 changes: 6 additions & 3 deletions plugins/ledmatrix-weather/radar.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,16 @@ def refresh_data(self, width: int, height: int) -> None:
self._radar_frames = new_frames
self._frame_timestamps = new_timestamps
self._frame_index = 0
self._last_fetch = time.time()
logger.info(f"[Radar] Loaded {len(new_frames)} radar frames")
if failed:
logger.warning(f"[Radar] {failed}/{len(frames_to_fetch)} tile(s) failed to load")
else:
logger.error(f"[Radar] All {len(frames_to_fetch)} radar tile(s) failed to load")

self._last_fetch = time.time()
# Don't update _last_fetch to full interval — retry in 60s
# instead of waiting the full 300s. Prevents stale frames
# persisting when tile CDN is temporarily unreachable.
self._last_fetch = time.time() - 240
logger.error(f"[Radar] All {len(frames_to_fetch)} radar tile(s) failed to load, retrying in 60s")
Comment on lines +317 to +321

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Retry interval calculation assumes 300s, but default is 600s.

The comment states "retry in 60s instead of 300s", but radar_update_interval defaults to 600s (see manager.py:109-112). With a 600s interval and -240 offset, the actual retry delay is 360 seconds, not 60s.

To achieve a ~60s retry:

  • For 300s interval: offset should be 300 - 60 = 240
  • For 600s interval: offset should be 600 - 60 = 540

Consider either:

  1. Using a fixed short interval for failure retries (e.g., store a retry timestamp directly)
  2. Adjusting the offset to interval - 60 dynamically
Option: Use a retry-specific backoff instead of hardcoded offset
+    # Retry interval on total failure (seconds)
+    _RETRY_INTERVAL = 60
+
     def needs_refresh(self, interval: int = 300) -> bool:
         """Return True when radar data is stale and should be refreshed."""
         return time.time() - self._last_fetch >= interval

Then in the failure path:

         else:
-            # Don't update _last_fetch to full interval — retry in 60s
-            # instead of waiting the full 300s. Prevents stale frames
-            # persisting when tile CDN is temporarily unreachable.
-            self._last_fetch = time.time() - 240
-            logger.error(f"[Radar] All {len(frames_to_fetch)} radar tile(s) failed to load, retrying in 60s")
+            # Set _last_fetch so next refresh happens in ~60s regardless of configured interval
+            self._last_fetch = time.time() - (interval - self._RETRY_INTERVAL) if interval > self._RETRY_INTERVAL else time.time()
+            logger.error(f"[Radar] All {len(frames_to_fetch)} radar tile(s) failed to load, retrying in ~{self._RETRY_INTERVAL}s")

This requires passing interval to refresh_data() or storing it as an instance attribute.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/ledmatrix-weather/radar.py` around lines 317 - 321, The retry logic
incorrectly assumes a 300s update interval when subtracting 240 from
self._last_fetch; change it to compute the offset from the actual
radar_update_interval or use an explicit retry timestamp: either set
self._last_fetch = time.time() - (self.radar_update_interval - 60) (ensure
radar_update_interval is available on the instance) or introduce a dedicated
self._next_retry = time.time() + 60 and update refresh_data() (or the method
handling fetch scheduling) to check that timestamp instead of deriving it from
_last_fetch; update the error log accordingly to reflect the actual retry delay.


def needs_refresh(self, interval: int = 300) -> bool:
"""Return True when radar data is stale and should be refreshed."""
Expand Down