Skip to content

Set Device Busy State

Set the busy state of a device to identify whether the device is executing tasks, facilitating device conflict avoidance during multi-script collaboration.

Interface Description

Interface Type

setDeviceBusy

Parameters

ParameterTypeRequiredDescription
deviceIdstringDevice ID
statebooleanBusy state, true=busy, false=idle

Return Value

javascript
true  // Returns true on successful operation

Event Notifications

When setting the state, events are triggered and broadcast via WebSocket:

  • Triggers device:busy event when set to busy
  • Triggers device:idle event when set to idle

Basic Usage

javascript
// Set device to busy state
await apiInvoke('setDeviceBusy', {
    deviceId: 'P72578581E07',
    state: true
});

// Execute tasks...

// Set to idle state after task completion
await apiInvoke('setDeviceBusy', {
    deviceId: 'P72578581E07',
    state: false
});

Notes

Device Lock

When a device is set to busy state (state: true), the system will automatically lock the corresponding device control panel to prevent interference from accidental operations during script execution.

Tips

  • The device's busying state can be obtained through the getDevices interface
  • It is recommended to promptly restore to idle state after task completion or exception to unlock the control panel

Cooperation: try.catch@foxmail.com