From fd8aee3227d8f98e0fa844b4583efafd975ca85b Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Wed, 17 Dec 2025 18:40:19 +0100 Subject: [PATCH] Fix device control response returning stale state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/controllers/housekeeping_controller.py | 4 ++++ 1 file changed, 4 insertions(+) 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)