diff --git a/apps/api/routes/rooms.py b/apps/api/routes/rooms.py index f076439..7458e12 100644 --- a/apps/api/routes/rooms.py +++ b/apps/api/routes/rooms.py @@ -48,11 +48,11 @@ class HeatingControlRequest(BaseModel): target: float # Target temperature -def get_room_devices(room_name: str) -> list[dict[str, Any]]: +def get_room_devices(room_id: str) -> list[dict[str, Any]]: """Get all devices in a specific room from layout. Args: - room_name: Name of the room + room_id: ID of the room Returns: List of device dicts with device_id, title, icon, rank, excluded @@ -63,7 +63,7 @@ def get_room_devices(room_name: str) -> list[dict[str, Any]]: layout = load_layout() for room in layout.rooms: - if room.name == room_name: + if room.id == room_id: return [ { "device_id": device.device_id, @@ -77,16 +77,16 @@ def get_room_devices(room_name: str) -> list[dict[str, Any]]: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail=f"Room '{room_name}' not found" + detail=f"Room '{room_id}' not found" ) -@router.post("/rooms/{room_name}/lights", status_code=status.HTTP_202_ACCEPTED) -async def control_room_lights(room_name: str, request: LightsControlRequest) -> dict[str, Any]: +@router.post("/rooms/{room_id}/lights", status_code=status.HTTP_202_ACCEPTED) +async def control_room_lights(room_id: str, request: LightsControlRequest) -> dict[str, Any]: """Control all lights (light and relay devices) in a room. Args: - room_name: Name of the room + room_id: ID of the room request: Light control parameters Returns: @@ -95,7 +95,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) -> from apps.api.main import load_devices, publish_abstract_set # Get all devices in room - room_devices = get_room_devices(room_name) + room_devices = get_room_devices(room_id) # Filter out excluded devices room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)} @@ -112,7 +112,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) -> if not light_devices: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail=f"No light devices found in room '{room_name}'" + detail=f"No light devices found in room '{room_id}'" ) # Build payload @@ -141,7 +141,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) -> }) return { - "room": room_name, + "room": room_id, "command": "lights", "payload": payload, "affected_devices": affected_ids, @@ -151,12 +151,12 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) -> } -@router.post("/rooms/{room_name}/heating", status_code=status.HTTP_202_ACCEPTED) -async def control_room_heating(room_name: str, request: HeatingControlRequest) -> dict[str, Any]: +@router.post("/rooms/{room_id}/heating", status_code=status.HTTP_202_ACCEPTED) +async def control_room_heating(room_id: str, request: HeatingControlRequest) -> dict[str, Any]: """Control all thermostats in a room. Args: - room_name: Name of the room + room_id: ID of the room request: Heating control parameters Returns: @@ -165,7 +165,7 @@ async def control_room_heating(room_name: str, request: HeatingControlRequest) - from apps.api.main import load_devices, publish_abstract_set # Get all devices in room - room_devices = get_room_devices(room_name) + room_devices = get_room_devices(room_id) # Filter out excluded devices room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)} @@ -209,7 +209,7 @@ async def control_room_heating(room_name: str, request: HeatingControlRequest) - }) return { - "room": room_name, + "room": room_id, "command": "heating", "payload": payload, "affected_devices": affected_ids, diff --git a/config/layout.yaml b/config/layout.yaml index 3d55084..8091ad4 100644 --- a/config/layout.yaml +++ b/config/layout.yaml @@ -1,5 +1,5 @@ rooms: -- id: Schlafzimmer +- id: schlafzimmer name: Schlafzimmer devices: - device_id: bettlicht_patty @@ -34,7 +34,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 47 -- id: Esszimmer +- id: esszimmer name: Esszimmer devices: - device_id: deckenlampe_esszimmer @@ -81,7 +81,7 @@ rooms: title: Kontakt Straße links icon: 🪟 rank: 97 -- id: Wohnzimmer +- id: wohnzimmer name: Wohnzimmer devices: - device_id: lampe_naehtischchen_wohnzimmer @@ -124,7 +124,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 138 -- id: Küche +- id: kueche name: Küche devices: - device_id: kueche_deckenlampe @@ -168,7 +168,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 155 -- id: Arbeitszimmer Patty +- id: arbeitszimmer_patty name: Arbeitszimmer Patty devices: - device_id: leselampe_patty @@ -211,7 +211,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 189 -- id: Arbeitszimmer Wolfgang +- id: arbeitszimmer_wolfgang name: Arbeitszimmer Wolfgang devices: - device_id: thermostat_wolfgang @@ -230,7 +230,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 202 -- id: Flur +- id: flur name: Flur devices: - device_id: deckenlampe_flur_oben @@ -257,7 +257,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 235 -- id: Sportzimmer +- id: sportzimmer name: Sportzimmer devices: - device_id: sportlicht_regal @@ -276,7 +276,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 265 -- id: Bad Oben +- id: bad_oben name: Bad Oben devices: - device_id: thermostat_bad_oben @@ -291,7 +291,7 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 272 -- id: Bad Unten +- id: bad_unten name: Bad Unten devices: - device_id: thermostat_bad_unten @@ -306,14 +306,14 @@ rooms: title: Temperatur & Luftfeuchte icon: 🌡️ rank: 282 -- id: Waschküche +- id: waschkueche name: Waschküche devices: - device_id: sensor_waschkueche title: Temperatur & Luftfeuchte icon: 🌡️ rank: 290 -- id: Outdoor +- id: outdoor name: Outdoor devices: - device_id: licht_terasse @@ -324,7 +324,7 @@ rooms: title: Gartenlicht vorne icon: 💡 rank: 291 -- id: Garage +- id: garage name: Garage devices: - device_id: power_relay_caroutlet