From 91fdfde2802f02c8f999fdfea117abecd5e69d66 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 19 Nov 2025 10:41:39 +0100 Subject: [PATCH] device state setting fix 7 --- apps/api/main.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/api/main.py b/apps/api/main.py index e085e4e..13f764e 100644 --- a/apps/api/main.py +++ b/apps/api/main.py @@ -365,6 +365,17 @@ async def publish_mqtt(topic: str, payload: dict[str, Any]) -> None: await client.publish(topic, message, qos=1) +@app.get("/devices/states") +async def get_device_states() -> dict[str, dict[str, Any]]: + """Get current states of all devices from in-memory cache. + + Returns: + dict: Dictionary mapping device_id to state payload + """ + logger.debug("Fetching all device states") + return device_states + + @app.get("/devices/{device_id}") async def get_device(device_id: str) -> DeviceInfo: logger.debug(f"Fetching info for device {device_id}") @@ -379,6 +390,7 @@ async def get_device(device_id: str) -> DeviceInfo: features=device.get("features", {}) ) + @app.get("/devices") async def get_devices() -> list[DeviceInfo]: """Get list of available devices. @@ -399,16 +411,6 @@ async def get_devices() -> list[DeviceInfo]: ] -@app.get("/devices/states") -async def get_device_states() -> dict[str, dict[str, Any]]: - """Get current states of all devices from in-memory cache. - - Returns: - dict: Dictionary mapping device_id to state payload - """ - logger.debug("Fetching all device states") - return device_states - @app.get("/layout") async def get_layout() -> dict[str, Any]: