Skip to main content
Glama
kaeljune

Fibaro HC3 MCP Server

by kaeljune

fibaro_control_rgb_light

Control RGB lights on Fibaro HC3: turn on/off, set color, and adjust brightness in a single command for unified lighting management.

Instructions

Complete control for RGB lights: turn on/off, set color, and brightness in one command. Use this when user wants to control multiple aspects of an RGB light at once (e.g., "turn on light 5 red color at 50% brightness").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesDevice ID
actionYesTurn light on or off
color_nameNoColor name (e.g., "red", "green", "blue", "xanh lá", "tím")
brightnessNoBrightness level (0-100), optional

Implementation Reference

  • The handler for the fibaro_control_rgb_light tool. It handles turning the device on/off, setting RGB color from color name using getColorRGB, and adjusting brightness, composing multiple operations into one tool call.
    case 'fibaro_control_rgb_light': {
      if (!this.fibaroClient) {
        throw new Error('Not connected to Fibaro HC3. Please check your configuration and restart the MCP server.');
      }
      const deviceId = args?.id as number;
      const action = args?.action as string;
      const colorName = args?.color_name as string;
      const brightness = args?.brightness as number;
    
      const results = [];
    
      // First, turn on/off the light
      if (action === 'on') {
        await this.fibaroClient.turnOnDevice(deviceId);
        results.push(`Turned on device ${deviceId}`);
      } else if (action === 'off') {
        await this.fibaroClient.turnOffDevice(deviceId);
        results.push(`Turned off device ${deviceId}`);
      }
    
      // Set color if specified
      if (colorName && action === 'on') {
        const rgb = getColorRGB(colorName);
        await this.fibaroClient.setColor(deviceId, rgb.r, rgb.g, rgb.b, 0);
        results.push(`Set color to ${colorName} RGB(${rgb.r},${rgb.g},${rgb.b})`);
      }
    
      // Set brightness if specified
      if (brightness !== undefined && action === 'on') {
        await this.fibaroClient.setBrightness(deviceId, brightness);
        results.push(`Set brightness to ${brightness}%`);
      }
    
      return {
        content: [
          {
            type: 'text',
            text: `Device ${deviceId}: ${results.join(', ')}`,
          },
        ],
      };
    }
  • Input schema defining parameters for the fibaro_control_rgb_light tool: device id (required), action (on/off required), optional color_name and brightness.
    inputSchema: {
      type: 'object',
      properties: {
        id: {
          type: 'number',
          description: 'Device ID',
        },
        action: {
          type: 'string',
          enum: ['on', 'off'],
          description: 'Turn light on or off',
        },
        color_name: {
          type: 'string',
          description: 'Color name (e.g., "red", "green", "blue", "xanh lá", "tím")',
        },
        brightness: {
          type: 'number',
          description: 'Brightness level (0-100), optional',
          minimum: 0,
          maximum: 100,
        },
      },
      required: ['id', 'action'],
    },
  • src/index.ts:272-300 (registration)
    Registration of the fibaro_control_rgb_light tool in the ListTools response, including name, description, and input schema.
    {
      name: 'fibaro_control_rgb_light',
      description: 'Complete control for RGB lights: turn on/off, set color, and brightness in one command. Use this when user wants to control multiple aspects of an RGB light at once (e.g., "turn on light 5 red color at 50% brightness").',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'number',
            description: 'Device ID',
          },
          action: {
            type: 'string',
            enum: ['on', 'off'],
            description: 'Turn light on or off',
          },
          color_name: {
            type: 'string',
            description: 'Color name (e.g., "red", "green", "blue", "xanh lá", "tím")',
          },
          brightness: {
            type: 'number',
            description: 'Brightness level (0-100), optional',
            minimum: 0,
            maximum: 100,
          },
        },
        required: ['id', 'action'],
      },
    },
  • Supporting utility function that converts color names (including Vietnamese) to RGB values, used in the tool handler for color setting.
    function getColorRGB(colorName: string): { r: number; g: number; b: number } {
      const colors: { [key: string]: { r: number; g: number; b: number } } = {
        'red': { r: 255, g: 0, b: 0 },
        'green': { r: 0, g: 255, b: 0 },
        'blue': { r: 0, g: 0, b: 255 },
        'yellow': { r: 255, g: 255, b: 0 },
        'purple': { r: 128, g: 0, b: 128 },
        'pink': { r: 255, g: 192, b: 203 },
        'orange': { r: 255, g: 165, b: 0 },
        'cyan': { r: 0, g: 255, b: 255 },
        'magenta': { r: 255, g: 0, b: 255 },
        'white': { r: 255, g: 255, b: 255 },
        'black': { r: 0, g: 0, b: 0 },
        'lime': { r: 50, g: 205, b: 50 },
        'violet': { r: 238, g: 130, b: 238 },
        // Vietnamese color names
        'đỏ': { r: 255, g: 0, b: 0 },
        'xanh lá': { r: 0, g: 255, b: 0 },
        'xanh dương': { r: 0, g: 0, b: 255 },
        'vàng': { r: 255, g: 255, b: 0 },
        'tím': { r: 128, g: 0, b: 128 },
        'hồng': { r: 255, g: 192, b: 203 },
        'cam': { r: 255, g: 165, b: 0 },
        'trắng': { r: 255, g: 255, b: 255 },
        'đen': { r: 0, g: 0, b: 0 }
      };
      
      const normalizedName = colorName.toLowerCase().trim();
      return colors[normalizedName] || { r: 255, g: 255, b: 255 }; // default to white
    }

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/kaeljune/fibaro-mcp-server'

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