device state setting fix
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user