control_shades
Control motorized shades by opening, closing, or setting precise positions using the Bond Bridge smart home system.
Instructions
Control motorized shades.
Args: device_id: The Bond shade device identifier action: Action to perform ("open", "close", or "set_position") position: Position percentage (0-100) when action is "set_position"
Returns: Result of the shade control operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | ||
| action | Yes | ||
| position | No |
Implementation Reference
- src/bond_mcp/server.py:218-256 (handler)The handler function for the 'control_shades' MCP tool. It validates inputs, calls appropriate BondClient methods (open_shades, close_shades, set_position), and returns the result or error.@mcp.tool() async def control_shades(device_id: str, action: str, position: Optional[int] = None) -> Dict[str, Any]: """Control motorized shades. Args: device_id: The Bond shade device identifier action: Action to perform ("open", "close", or "set_position") position: Position percentage (0-100) when action is "set_position" Returns: Result of the shade control operation. """ valid_actions = ["open", "close", "set_position"] if action.lower() not in valid_actions: return {"error": f"Action must be one of: {', '.join(valid_actions)}"} if action.lower() == "set_position" and (position is None or not (0 <= position <= 100)): return {"error": "Position must be between 0 and 100 when setting position"} try: async with await get_bond_client() as client: if action.lower() == "open": result = await client.open_shades(device_id) elif action.lower() == "close": result = await client.close_shades(device_id) else: # set_position result = await client.set_position(device_id, position) return { "device_id": device_id, "action": action.lower(), "position": position if action.lower() == "set_position" else None, "result": result } except BondAPIError as e: return {"error": f"Failed to control shades: {str(e)}"} except Exception as e: logger.error(f"Unexpected error controlling shades: {e}") return {"error": f"Unexpected error: {str(e)}"}