Dynamics of vibration devices, which elements or units interact with liquid or air medium, is studied. Two types of vibration devices are considered. The first one is a vibration machine with constant air or liquid flow excitation. The main idea is to find out optimal control law for variation of additional surface area of machine working head interacting with external medium. The criterion of optimization is time required to move working head of the machine from initial position to end position. The second object of the study is a fin type propulsive device of robotic fish moving inside water. The aim of the study is to find out optimal control law for variation of additional area of vibrating tail, which ensures maximal positive impulse of motive forces acting on tail. Both problems have been solved using the maximum principle of Pontryagin. It is shown that optimal control action corresponds to the case of bound values of area limits. Examples on synthesis of real mechatronic systems are given.