Device

class buttplug.client.ButtplugClientDevice(client: buttplug.client.client.ButtplugClient, device_msg: Union[buttplug.core.messages.DeviceInfo, buttplug.core.messages.DeviceAdded])

Represents a device that is connected to the Buttplug Server.

name

Name of the device

Type

string

allowed_messages

Dictionary that matches message names to attributes. For instance, if a device can vibrate, it will have a dictionary entry for “VibrateCmd”, as well as a MessageAttribute for “FeatureCount” that says how many vibrators are in the device.

Type

Dict[str, MessageAttributes]

async send_linear_cmd(linear: Union[Tuple[int, float], List[Tuple[int, float]], Dict[int, Tuple[int, float]]])

Tell the server to make a device stroke (move linearly) at a certain speed. Use StopDeviceCmd to stop the device from moving.

Parameters

linear (Union[Tuple[int, float], List[Tuple[int, float]], Dict[int, Tuple[int, float]]]) –

Linear position(s) and movement duration(s), to set the hardware to, assuming the hardware supports linear movement. Position range is from 0.0 <= x <= 1.0. Duration is in milliseconds, 1000ms = 1s.

Types accepted:

  • a Tuple of [int, float], which all linear hardware is set to.

  • a list of Tuple[int, float], mapping to the linear indexes in the hardware, i.e. [(1000, 0.9), (500, 0.1)] will set linear movement 0 to 90% position and move to it over 1s, while linear movement 1 will move to 10% position over 0.5s

  • a dict of Tuple[int, float], mapping to the linear indexes in the hardware, i.e. {0: (1000, 0.9), 1: (500, 0.1)} will set linear movement 0 to 90% position and move to it over 1s, while linear movement 1 will move to 10% position over 0.5s

async send_rotate_cmd(rotations: Union[Tuple[float, bool], List[Tuple[float, bool]], Dict[int, Tuple[float, bool]]])

Tell the server to make a device rotate at a certain speed. 0.0 for speed or using send_stop_device_cmd will stop the hardware from rotating.

Parameters

rotations (Union[Tuple[float, bool], List[Tuple[float, bool]], Dict[int, Tuple[float, bool]]]) –

Rotation speed(s) and directions, to set the hardware to, assuming the hardware supports rotation.. Range is from 0.0 <= x <= 1.0 for speeds. For bool, True is clockwise direction, False is counterclockwise.

Types accepted:

  • a Tuple of [float, bool], which all rotators will be set to

  • a list of Tuple[float, bool], mapping to the rotator indexes in the hardware, i.e. [(0.5, False), (1.0, True)] will set motor 0 to 50% speed going counterclockwise, motor 1 to 100% speed going clockwise.

  • a dict of int to Tuple[float, bool], mapping rotator indexes in the hardware, i.e. { 0: (0.5, False), 1: (1.0, True)} will set motor 0 to 50% speed going counterclockwise, motor 1 to 100% speed going clockwise.

async send_stop_device_cmd()

Tell the server to stop whatever device movements may be happening.

async send_vibrate_cmd(speeds: Union[float, List[float], Dict[int, float]])

Tell the server to make a device vibrate at a certain speed. 0.0 for speed or using send_stop_device_cmd will stop the hardware from vibrating.

Parameters

speeds (Union[float, List[float], Dict[int, float]]) –

Speed, or speeds, to set the vibrators to, assuming the hardware supports vibration. Range is from 0.0 <= x <= 1.0.

Types accepted:

  • a single float, which all vibration motors will be set to

  • a list of floats, mapping to the motor indexes in the hardware, i.e. [0.5, 1.0] will set motor 0 to 0.5, motor 1 to 1.

  • a dict of int to float, which maps motor index to speed. i.e. { 0: 0.5, 1: 1.0 } will set motor 0 to 0.5, motor 1 to 1.