Skip to main content
Glama
madorn
by madorn

set_light_brightness

Adjust dimmable light brightness levels by specifying a percentage value from 0 (off) to 100 (maximum) for Bond Bridge smart home devices.

Instructions

Set brightness for a dimmable light device.

Args: device_id: The Bond light device identifier brightness: Brightness percentage (0-100, where 0 is off)

Returns: Result of the brightness change operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idYes
brightnessYes

Implementation Reference

  • The handler function for the 'set_light_brightness' tool. It is registered via the @mcp.tool() decorator. Validates input brightness, interacts with BondClient to dim or turn off the light, handles errors, and returns a result dictionary.
    @mcp.tool()
    async def set_light_brightness(device_id: str, brightness: int) -> Dict[str, Any]:
        """Set brightness for a dimmable light device.
        
        Args:
            device_id: The Bond light device identifier
            brightness: Brightness percentage (0-100, where 0 is off)
            
        Returns:
            Result of the brightness change operation.
        """
        if not (0 <= brightness <= 100):
            return {"error": "Brightness must be between 0 and 100"}
        
        try:
            async with await get_bond_client() as client:
                if brightness == 0:
                    result = await client.turn_off(device_id)
                    action = "turned off"
                else:
                    result = await client.dim_light(device_id, brightness)
                    action = f"set to {brightness}% brightness"
                
                return {
                    "device_id": device_id,
                    "brightness": brightness,
                    "action": action,
                    "result": result
                }
        except BondAPIError as e:
            return {"error": f"Failed to set light brightness: {str(e)}"}
        except Exception as e:
            logger.error(f"Unexpected error setting light brightness: {e}")
            return {"error": f"Unexpected error: {str(e)}"}

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/madorn/bond-mcp-server'

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