activate_scene
Activate a LIFX smart lighting scene to set specific colors, brightness, and effects across multiple lights simultaneously using a scene UUID.
Instructions
Activate a scene
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | LIFX API token | |
| scene_uuid | Yes | Scene UUID | |
| duration | No | Duration in seconds | |
| fast | No | Fast mode (skip confirmation) |
Implementation Reference
- src/index.ts:437-463 (handler)Handler for the activate_scene tool. Extracts parameters, constructs request body, calls LIFX API to activate the scene, and returns success message with result.case "activate_scene": { const { token, scene_uuid, duration, fast } = args as { token: string; scene_uuid: string; duration?: number; fast?: boolean; }; const body = Object.fromEntries( Object.entries({ duration, fast }).filter(([_, value]) => value !== undefined) ); const result = await makeLIFXRequest(`/scenes/scene_id:${scene_uuid}/activate`, { method: "PUT", body, token, }); return { content: [ { type: "text", text: `Scene activated successfully. ${JSON.stringify(result, null, 2)}`, }, ], }; }
- src/index.ts:234-247 (schema)Schema definition for activate_scene tool including input parameters validation.{ name: "activate_scene", description: "Activate a scene", inputSchema: { type: "object", properties: { token: { type: "string", description: "LIFX API token" }, scene_uuid: { type: "string", description: "Scene UUID" }, duration: { type: "number", minimum: 0, description: "Duration in seconds" }, fast: { type: "boolean", description: "Fast mode (skip confirmation)" }, }, required: ["token", "scene_uuid"], }, },
- src/index.ts:72-114 (helper)Helper function used by activate_scene to make authenticated HTTP requests to LIFX API.async function makeLIFXRequest( endpoint: string, options: { method?: string; body?: any; token: string; } ): Promise<any> { const { method = "GET", body, token } = options; const url = `${LIFX_API_BASE}${endpoint}`; const headers: Record<string, string> = { "Authorization": `Bearer ${token}`, "User-Agent": USER_AGENT, }; if (body && (method === "POST" || method === "PUT")) { headers["Content-Type"] = "application/json"; } try { const response = await fetch(url, { method, headers, body: body ? JSON.stringify(body) : undefined, }); if (!response.ok) { const errorText = await response.text(); throw new Error(`LIFX API error: ${response.status} ${response.statusText} - ${errorText}`); } // Some endpoints return empty responses const contentType = response.headers.get("content-type"); if (contentType?.includes("application/json")) { return await response.json(); } return await response.text(); } catch (error) { throw new Error(`Failed to make LIFX API request: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:51-69 (schema)Type definition for LIFX scenes used in related tools.interface LIFXScene { uuid: string; name: string; account: { uuid: string; }; states: Array<{ selector: string; power: string; brightness: number; color: { hue: number; saturation: number; kelvin: number; }; }>; created_at: number; updated_at: number; }