Commands & Batch Operations
Send commands to individual devices or execute batch operations across multiple devices.
Source: src/commands/
Permission: MANAGE_REMOTE_CONTROL
Architecture
Single Commands
CommandsService handles individual device commands:
- Validate command permissions
- Send via
EventsService.sendCommandToDevice()(WebSocket) - Store in
CommandHistory - Listen for response via
commandResponse$Subject - Update history and notify user via WebSocket
Batch Commands
BatchCommandService handles multi-device operations:
- Parallel (default) or sequential execution
- Max 50 concurrent commands
- Default 30-second timeout per command
- Progress tracked in-memory via
activeBatchesMap
Command Permission Levels
// Admin-only (destructive)
ADMIN_ONLY: ['clear_data', 'remote_install', 'factory_reset',
'disable_app', 'uninstall_app', 'change_system_settings',
'modify_security', 'kiosk_mode', 'lock_mode', 'enable_kiosk',
'disable_kiosk', 'reconnect_wifi', 'reset_network']
// Advanced (admin or special permission)
ADVANCED: ['clear_cache', 'force_stop', 'grant_permission',
'revoke_permission', 'change_brightness', 'change_volume',
'update_firmware']
Batch Execution Flow
executeBatchCommand()
├─ Generate batchId
├─ Save to BatchCommand DB record
├─ Sequential mode:
│ └─ Execute one at a time, await each
└─ Parallel mode:
└─ Fire all via MQTT, track in activeBatches Map
Prisma Models
CommandHistory— Individual command recordsBatchCommand— Batch operation metadataBatchCommandResult— Per-device results within a batch
Related Modules
EventsModule— WebSocket command delivery and response handlingMqttModule— MQTT command deliveryRemoteControlModule— Higher-level remote control operations