Fix device control response returning stale state

Add 300ms delay after executing device action before fetching new state,
allowing Home Assistant time to update the entity state.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-17 18:40:19 +01:00
co-authored by Claude Opus 4.5
parent afb47c48d4
commit fd8aee3227
@@ -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)