garaga page 7

This commit is contained in:
2025-11-28 07:55:53 +01:00
parent 86409b26f0
commit b4e0fc8ddd

View File

@@ -512,7 +512,10 @@
async function toggleOutlet(deviceId, newState) { async function toggleOutlet(deviceId, newState) {
try { try {
const device = devicesData[deviceId]; const device = devicesData[deviceId];
await window.apiClient.setDeviceState(deviceId, device.type, { power: newState }); await sendCommand(deviceId, {
type: device.type,
payload: { power: newState }
});
console.log(`Set ${deviceId} to ${newState}`); console.log(`Set ${deviceId} to ${newState}`);
} catch (error) { } catch (error) {
console.error('Error toggling outlet:', error); console.error('Error toggling outlet:', error);
@@ -520,6 +523,11 @@
} }
} }
async function sendCommand(deviceId, payload) {
const device = devicesData[deviceId];
await window.apiClient.setDeviceState(deviceId, device.type, payload.payload);
}
function connectRealtime() { function connectRealtime() {
try { try {
window.apiClient.connectRealtime((event) => { window.apiClient.connectRealtime((event) => {