diff --git a/apps/ui/templates/room.html b/apps/ui/templates/room.html index b225285..8183a37 100644 --- a/apps/ui/templates/room.html +++ b/apps/ui/templates/room.html @@ -289,15 +289,14 @@ return; } - // Load all device states at once - // NEW: Use device state endpoint for each device - // Fallback: load all states as before - const allStates = await window.apiClient.getAllStates(); - // Example: For each device in room.devices, you could fetch state via - // await window.apiClient.getDeviceState(device_id); - roomDevices.forEach(device => { - deviceStates[device.device_id] = allStates[device.device_id] || null; - }); + // Lade nur die States für die Geräte im aktuellen Raum + for (const device of roomDevices) { + try { + deviceStates[device.device_id] = await window.apiClient.getDeviceState(device.device_id); + } catch (err) { + deviceStates[device.device_id] = null; + } + } // Render devices grid.style.display = 'grid';