From a382d5860114aad436b198434ed88470de4b5997 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 19 Nov 2025 10:11:16 +0100 Subject: [PATCH] device state setting fix --- apps/api/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/api/main.py b/apps/api/main.py index 4c8796f..13139f4 100644 --- a/apps/api/main.py +++ b/apps/api/main.py @@ -362,6 +362,21 @@ async def publish_mqtt(topic: str, payload: dict[str, Any]) -> None: await client.publish(topic, message, qos=1) +@app.get("/devices/{device_id}") +async def get_device(device_id: str) -> DeviceInfo: + devices = load_devices() + + try: + device = devices[device_id] + return DeviceInfo( + device_id=device["device_id"], + type=device["type"], + name=device.get("name", device["device_id"]), + features=device.get("features", {}) + ) + except KeyError: + raise HTTPException(status_code=404, detail="Device not found") + @app.get("/devices") async def get_devices() -> list[DeviceInfo]: """Get list of available devices.