You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return"The Home Assistant / IoT connector is not connected yet. Please instruct the user to go to Settings > Connectors to connect it (either in real or simulated mode).";
return`Failed to execute control service on Home Assistant. Status: ${haRes.status}`;
315
+
}
316
+
}catch(err: any){
317
+
return`Error contacting Home Assistant API: ${err.message||err}`;
318
+
}
319
+
}
320
+
321
+
// Persist the updated state back to the database
322
+
metadata.devices={
323
+
...devices,
324
+
[entityId]: updatedDevice,
325
+
};
326
+
327
+
awaitdb
328
+
.update(connectorAccounts)
329
+
.set({
330
+
metadataJson: JSON.stringify(metadata),
331
+
updatedAt: newDate().toISOString(),
332
+
})
333
+
.where(eq(connectorAccounts.id,account.id));
334
+
335
+
return`Successfully set ${entityId} to state: "${state}"${brightness!==undefined ? ` with brightness ${brightness}` : ""}${temperature!==undefined ? ` at temperature ${temperature}°C` : ""}.`;
description: "Control a connected smart home device by changing its state (e.g. turn on a light, lock a door, set thermostat temperature).",
343
+
schema: z.object({
344
+
entityId: z.string().describe("The entity ID of the device (e.g., 'light.living_room', 'switch.kitchen_fan', 'lock.front_door', 'climate.thermostat')"),
345
+
state: z.string().describe("The target state for the device (e.g., 'on', 'off', 'lock', 'unlock', 'heat')"),
346
+
brightness: z.number().min(0).max(255).optional().describe("Optional brightness level (0-255) for lights only"),
347
+
temperature: z.number().optional().describe("Optional target temperature value for climate/thermostat devices only"),
348
+
}),
349
+
}
350
+
);
351
+
212
352
exportasyncfunctionPOST(req: Request){
213
353
constsession=awaitrequireSession(req);
214
354
if(sessioninstanceofNextResponse)returnsession;
@@ -351,6 +491,8 @@ export async function POST(req: Request) {
0 commit comments