garaga page 7
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user