device state fix
This commit is contained in:
@@ -231,21 +231,11 @@ async def get_device_layout(device_id: str):
|
|||||||
|
|
||||||
@app.get("/devices/{device_id}/state")
|
@app.get("/devices/{device_id}/state")
|
||||||
async def get_device_state(device_id: str):
|
async def get_device_state(device_id: str):
|
||||||
"""Gibt den aktuellen State für ein einzelnes Gerät zurück."""
|
try:
|
||||||
state_path = Path(__file__).parent.parent.parent / "config" / "devices.yaml"
|
state = device_states[device_id]
|
||||||
if not state_path.exists():
|
return state
|
||||||
raise HTTPException(status_code=500, detail="State file not found")
|
except KeyError:
|
||||||
with open(state_path, "r") as f:
|
|
||||||
config = yaml.safe_load(f)
|
|
||||||
states = config.get("states", {})
|
|
||||||
state = states.get(device_id)
|
|
||||||
if state is None:
|
|
||||||
raise HTTPException(status_code=404, detail="Device state not found")
|
raise HTTPException(status_code=404, detail="Device state not found")
|
||||||
return state
|
|
||||||
# --- Minimal-invasive: Einzelgerät-Layout-Endpunkt ---
|
|
||||||
from fastapi import Query
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --- Minimal-invasive: Einzelgerät-Layout-Endpunkt ---
|
# --- Minimal-invasive: Einzelgerät-Layout-Endpunkt ---
|
||||||
@app.get("/devices/{device_id}/layout")
|
@app.get("/devices/{device_id}/layout")
|
||||||
|
|||||||
Reference in New Issue
Block a user