set_light_brightness
Adjust dimmable light brightness levels through the Bond MCP Server by specifying device ID and percentage (0-100). Control smart lighting devices by setting precise brightness values for customized illumination.
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
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | ||
| brightness | Yes |
Implementation Reference
- src/bond_mcp/server.py:259-292 (handler)The main handler function for the 'set_light_brightness' tool. Decorated with @mcp.tool() for registration in FastMCP. Validates input, interacts with Bond client to dim light or turn off, and returns result or error.@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)}"}