From 8c07f72f6fdc9776a00c8eef647bdb5fab19e83a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:05:02 +0000 Subject: [PATCH 1/2] Initial plan From 668e56e30f8b7aa792ee2509b5233558614be107 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:14:04 +0000 Subject: [PATCH 2/2] Fix TemperatureAPI making API calls when disabled and showing unhealthy Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/1fe42cbb-3fc0-4288-8f4d-955796e16cbb Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com> --- apps/predbat/temperature.py | 5 ++++- apps/predbat/tests/test_temperature.py | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/predbat/temperature.py b/apps/predbat/temperature.py index c272cfabd..683419777 100644 --- a/apps/predbat/temperature.py +++ b/apps/predbat/temperature.py @@ -54,7 +54,10 @@ async def run(self, seconds, first): Main run loop - polls API every hour """ try: - if not self.temperature_enable: + # Re-read enable flag dynamically so runtime UI toggles are respected + temperature_enable = self.get_arg("temperature_enable", self.temperature_enable) + if not temperature_enable: + self.update_success_timestamp() return True if first or (seconds % (60 * 60) == 0): # Fetch temperature data every hour diff --git a/apps/predbat/tests/test_temperature.py b/apps/predbat/tests/test_temperature.py index 3ccbd29db..d22733963 100644 --- a/apps/predbat/tests/test_temperature.py +++ b/apps/predbat/tests/test_temperature.py @@ -60,6 +60,18 @@ def update_success_timestamp(self): def last_updated_time(self): return self._last_updated_time + def get_arg(self, arg, default=None, **kwargs): + """Mock get_arg - returns stored config values""" + if arg == "temperature_enable": + return self.temperature_enable + if arg == "temperature_latitude": + return self.temperature_latitude + if arg == "temperature_longitude": + return self.temperature_longitude + if arg == "temperature_url": + return self.temperature_url + return default + def get_state_wrapper(self, entity_id, default=None, attribute=None): """Mock get_state_wrapper""" if entity_id in self.state_storage: @@ -742,7 +754,11 @@ def run_test(): print(" ERROR: fetch_temperature_data should not be called when disabled") return 1 - print(" PASS: run returns True without fetching when disabled") + if temp_api._last_updated_time is None: + print(" ERROR: update_success_timestamp should be called when disabled to keep component healthy") + return 1 + + print(" PASS: run returns True without fetching when disabled, and marks component healthy") return 0 return run_test()