Skip to main content
Glama

pulse_effect

Create a pulsing color animation for LIFX smart lights by specifying colors, cycle duration, and brightness peaks to add dynamic lighting effects.

Instructions

Perform a pulse effect

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesLIFX API token
selectorNoSelector for filtering lights (default: 'all')
colorYesColor to pulse
from_colorNoStarting color
periodNoDuration of one cycle in seconds
cyclesNoNumber of cycles
persistNoPersist the final color
power_onNoTurn on if off
peakNoPeak brightness (0.0 to 1.0)

Implementation Reference

  • Handler for the 'pulse_effect' tool. Extracts parameters from input arguments, constructs the request body, and sends a POST request to the LIFX API endpoint `/lights/{selector}/effects/pulse` to initiate the pulse effect.
    case "pulse_effect": { const { token, selector = "all", ...effectParams } = args as { token: string; selector?: string; color: string; from_color?: string; period?: number; cycles?: number; persist?: boolean; power_on?: boolean; peak?: number; }; const body = Object.fromEntries( Object.entries(effectParams).filter(([_, value]) => value !== undefined) ); const result = await makeLIFXRequest(`/lights/${selector}/effects/pulse`, { method: "POST", body, token, }); return { content: [ { type: "text", text: `Pulse effect started for selector "${selector}". ${JSON.stringify(result, null, 2)}`, }, ], }; }
  • Schema and registration for the 'pulse_effect' tool, defining the input parameters, types, descriptions, and required fields in the ListTools response.
    { name: "pulse_effect", description: "Perform a pulse effect", inputSchema: { type: "object", properties: { token: { type: "string", description: "LIFX API token" }, selector: { type: "string", description: "Selector for filtering lights (default: 'all')" }, color: { type: "string", description: "Color to pulse" }, from_color: { type: "string", description: "Starting color" }, period: { type: "number", minimum: 0.1, description: "Duration of one cycle in seconds" }, cycles: { type: "number", minimum: 1, description: "Number of cycles" }, persist: { type: "boolean", description: "Persist the final color" }, power_on: { type: "boolean", description: "Turn on if off" }, peak: { type: "number", minimum: 0, maximum: 1, description: "Peak brightness (0.0 to 1.0)" }, }, required: ["token", "color"], }, },
  • Shared helper function 'makeLIFXRequest' used by the pulse_effect handler (and other tools) to perform authenticated HTTP requests to the 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)}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lenvolk/mcp-lifx'

If you have feedback or need assistance with the MCP directory API, please join our Discord server