diff --git a/apps/ui/templates/garage.html b/apps/ui/templates/garage.html
index 38a5f87..638063a 100644
--- a/apps/ui/templates/garage.html
+++ b/apps/ui/templates/garage.html
@@ -512,7 +512,10 @@
async function toggleOutlet(deviceId, newState) {
try {
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}`);
} catch (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() {
try {
window.apiClient.connectRealtime((event) => {