fix: append 'unknown' to history on timeout or client error

Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
2025-07-31 19:14:38 -06:00
parent 38ab26a659
commit a83f0d0937

View File

@@ -105,8 +105,14 @@ async def monitor_garage_door(app):
except asyncio.TimeoutError:
logging.warning("Request to camera timed out.")
PREDICTION_HISTORY.append('unknown')
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
PREDICTION_HISTORY.pop(0)
except aiohttp.ClientError as e:
logging.error(f"Client error during image fetch: {e}")
PREDICTION_HISTORY.append('unknown')
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
PREDICTION_HISTORY.pop(0)
except asyncio.CancelledError:
logging.info("Monitoring task cancelled.")
break