Spacing
This commit is contained in:
@@ -105,11 +105,13 @@ async def monitor_garage_door(app):
|
|||||||
|
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logging.warning("Request to camera timed out.")
|
logging.warning("Request to camera timed out.")
|
||||||
|
|
||||||
PREDICTION_HISTORY.append('unknown')
|
PREDICTION_HISTORY.append('unknown')
|
||||||
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
|
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
|
||||||
PREDICTION_HISTORY.pop(0)
|
PREDICTION_HISTORY.pop(0)
|
||||||
except aiohttp.ClientError as e:
|
except aiohttp.ClientError as e:
|
||||||
logging.error(f"Client error during image fetch: {e}")
|
logging.error(f"Client error during image fetch: {e}")
|
||||||
|
|
||||||
PREDICTION_HISTORY.append('unknown')
|
PREDICTION_HISTORY.append('unknown')
|
||||||
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
|
if len(PREDICTION_HISTORY) > PREDICTION_HISTORY_MAX_LENGTH:
|
||||||
PREDICTION_HISTORY.pop(0)
|
PREDICTION_HISTORY.pop(0)
|
||||||
@@ -130,11 +132,13 @@ async def handle_root(request):
|
|||||||
async def handle_state(request):
|
async def handle_state(request):
|
||||||
"""Handler for the /state GET request."""
|
"""Handler for the /state GET request."""
|
||||||
state = "unknown"
|
state = "unknown"
|
||||||
|
|
||||||
if len(PREDICTION_HISTORY) == PREDICTION_HISTORY_MAX_LENGTH:
|
if len(PREDICTION_HISTORY) == PREDICTION_HISTORY_MAX_LENGTH:
|
||||||
if all(s == "open" for s in PREDICTION_HISTORY):
|
if all(s == "open" for s in PREDICTION_HISTORY):
|
||||||
state = "open"
|
state = "open"
|
||||||
elif all(s == "closed" for s in PREDICTION_HISTORY):
|
elif all(s == "closed" for s in PREDICTION_HISTORY):
|
||||||
state = "closed"
|
state = "closed"
|
||||||
|
|
||||||
return web.Response(text=state)
|
return web.Response(text=state)
|
||||||
|
|
||||||
async def on_startup(app):
|
async def on_startup(app):
|
||||||
|
Reference in New Issue
Block a user