diff --git a/src/controllers/housekeeping_controller.py b/src/controllers/housekeeping_controller.py index 4b37421..3cb750f 100644 --- a/src/controllers/housekeeping_controller.py +++ b/src/controllers/housekeeping_controller.py @@ -4,6 +4,7 @@ Housekeeping Controller Provides API endpoints for home automation via Home Assistant. Designed for the Tatlock Housekeeper agent and other consumers. """ +import asyncio from fastapi import APIRouter, HTTPException, Query, Depends from typing import List, Dict, Any, Optional from pydantic import BaseModel, Field @@ -413,6 +414,9 @@ class HousekeepingController(BaseController): else: # toggle await ha.toggle(entity_id) + # Wait for HA to update state before fetching + await asyncio.sleep(0.3) + # Get new state new_state = await ha.get_state(entity_id)