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:
@@ -4,6 +4,7 @@ Housekeeping Controller
|
|||||||
Provides API endpoints for home automation via Home Assistant.
|
Provides API endpoints for home automation via Home Assistant.
|
||||||
Designed for the Tatlock Housekeeper agent and other consumers.
|
Designed for the Tatlock Housekeeper agent and other consumers.
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
from fastapi import APIRouter, HTTPException, Query, Depends
|
from fastapi import APIRouter, HTTPException, Query, Depends
|
||||||
from typing import List, Dict, Any, Optional
|
from typing import List, Dict, Any, Optional
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@@ -413,6 +414,9 @@ class HousekeepingController(BaseController):
|
|||||||
else: # toggle
|
else: # toggle
|
||||||
await ha.toggle(entity_id)
|
await ha.toggle(entity_id)
|
||||||
|
|
||||||
|
# Wait for HA to update state before fetching
|
||||||
|
await asyncio.sleep(0.3)
|
||||||
|
|
||||||
# Get new state
|
# Get new state
|
||||||
new_state = await ha.get_state(entity_id)
|
new_state = await ha.get_state(entity_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user