Skip to main content
Glama
lenvolk
by lenvolk

breathe_effect

Create a breathing light effect on LIFX smart bulbs by cycling colors with adjustable duration, cycles, and brightness for dynamic ambiance.

Instructions

Perform a breathe effect

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesLIFX API token
selectorNoSelector for filtering lights (default: 'all')
colorYesColor to breathe
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 function for 'breathe_effect' tool that constructs the request body from parameters and calls the LIFX API to start the breathe effect.
    case "breathe_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/breathe`, {
        method: "POST",
        body,
        token,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Breathe effect started for selector "${selector}". ${JSON.stringify(result, null, 2)}`,
          },
        ],
      };
    }
  • Tool definition including name, description, and JSON input schema for validation.
    {
      name: "breathe_effect",
      description: "Perform a breathe 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 breathe" },
          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"],
      },
  • Helper function used by the handler to make 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