diff --git a/apps/ui/templates/room.html b/apps/ui/templates/room.html index d1295d7..d7fd9a9 100644 --- a/apps/ui/templates/room.html +++ b/apps/ui/templates/room.html @@ -286,8 +286,11 @@ return; } - // Load initial states - await loadDeviceStates(roomDevices.map(d => d.device_id)); + // Load all device states at once + const allStates = await window.apiClient.getAllStates(); + roomDevices.forEach(device => { + deviceStates[device.device_id] = allStates[device.device_id] || null; + }); // Render devices grid.style.display = 'grid'; @@ -310,23 +313,6 @@ } } - async function loadDeviceStates(deviceIds) { - try { - // Load states for all devices using API client - const statePromises = deviceIds.map(async deviceId => { - try { - const state = await window.apiClient.getDeviceState(deviceId); - deviceStates[deviceId] = state; - } catch (e) { - console.warn(`Failed to load state for ${deviceId}:`, e); - } - }); - await Promise.all(statePromises); - } catch (error) { - console.error('Error loading device states:', error); - } - } - function createDeviceCard(device) { const card = document.createElement('a'); card.className = 'device-card';