Skip to main content
Glama

set_device_color

Change the color and brightness of Home Assistant lights by specifying RGB values to create custom lighting scenes and ambiance.

Instructions

Set the color and optionally brightness of a light entity.

Args: entity_id: The Home Assistant entity ID to control (format: light.entity) red: Red component (0-255) green: Green component (0-255) blue: Blue component (0-255) brightness: Optional brightness level (0-255)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blueYes
brightnessNo
entity_idYes
greenYes
redYes

Implementation Reference

  • The handler function that implements the 'set_device_color' tool logic: validates entity_id and RGB/brightness values, then calls the set_light_color helper to update the Home Assistant light entity.
    async def set_device_color(entity_id: str, red: int, green: int, blue: int, brightness: int = None) -> str: """Set the color and optionally brightness of a light entity. Args: entity_id: The Home Assistant entity ID to control (format: light.entity) red: Red component (0-255) green: Green component (0-255) blue: Blue component (0-255) brightness: Optional brightness level (0-255) """ # Basic validation if not entity_id or not entity_id.startswith("light."): return f"Invalid entity ID format: {entity_id}. Must be a light entity (format: light.entity)" # Validate RGB values for color, name in [(red, "Red"), (green, "Green"), (blue, "Blue")]: if not 0 <= color <= 255: return f"Invalid {name} value: {color}. Must be between 0 and 255" # Validate brightness if provided if brightness is not None and not 0 <= brightness <= 255: return f"Invalid brightness value: {brightness}. Must be between 0 and 255" # Check token if not HOME_ASSISTANT_TOKEN: return "Home Assistant token not configured. Set HOME_ASSISTANT_TOKEN environment variable." # Call the HA API result = await set_light_color(entity_id, [red, green, blue], brightness) if result["success"]: color_msg = f"color to RGB({red},{green},{blue})" brightness_msg = f" and brightness to {brightness}" if brightness is not None else "" return f"Successfully set {entity_id} {color_msg}{brightness_msg}" else: return f"Failed to set color for {entity_id}: {result.get('error', 'Unknown error')}"
  • Registers the set_device_color handler as an MCP tool using FastMCP's decorator.
    fastmcp_instance.tool()(set_device_color) # Register set_device_color like other tools

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/hpohlmann/home-assistant-mcp'

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