Make weather update interval configurable, was hardcoded to 30 min
Screen.poll_interval was a fixed class attribute the scheduler read directly -- added Screen.get_poll_interval(settings) so a screen can make it settings-driven instead. WeatherScreen overrides it to read a new "update_minutes" field (default 30, matching the old hardcoded value). New number input on the Weather settings page. Caught a real edge case while testing: `raw or 30` treats an explicit 0 as falsy and silently replaces it with 30 instead of clamping to the 1-minute floor. Not reachable via the UI (min="1" on the input) but the method should still be correct standalone -- fixed with an explicit None-check instead.
This commit is contained in:
1 parent
15c7c38d86
commit
889c062212
5 files changed
+29
-3
No files matched your search
+2
-1
@@ -180,8 +180,9 @@ class Scheduler:
|
||||
def _poll_screen(self, screen_id: str) -> tuple[str, object, bool]:
|
||||
cache = self._caches[screen_id]
|
||||
screen = self.screens[screen_id]
|
||||
settings = self.config.get_screen_settings(screen_id)
|
||||
checked = False
|
||||
if cache.is_stale(screen.poll_interval):
|
||||
if cache.is_stale(screen.get_poll_interval(settings)):
|
||||
cache.state = self._check(screen_id)
|
||||
cache.checked_at = time.time()
|
||||
checked = True
|
||||
|
||||
Reference in new issue
Block a user