Difference between revisions of "Trigger: USB Device Connect/Disconnect"

Line 1: Line 1:
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
<pre class="header-style">This trigger will fire when a USB device such as a memory stick or keyboard is connected or disconnected. It monitors for USB peripherals and accessories attached to your Android device.</pre>
This trigger will fire when a USB peripheral device such as a keyboard, mouse or USB memory stick is connected/disconnected from the Android phone/tablet.
 
  
Note that this trigger will not fire in the case where the Android device is connected to a PC or similar.
+
''' Options '''
</pre>
+
 
* ''When this trigger is present, you can use more [...]'' ''[https://macrodroidforum.com/wiki/index.php/Magic_text#USB_device_connected magic text]''
+
* '''USB Device Connected''': Trigger when a USB device is attached to the Android device
 +
* '''USB Device Disconnected''': Trigger when a USB device is detached from the Android device
 +
 
 +
''' Local Variables '''
 +
 
 +
This trigger provides the following magic text variables:
 +
 
 +
* '''USB product name''': The product name of the connected/disconnected USB device
 +
* '''USB manufacturer name''': The manufacturer name of the USB device
 +
* '''USB device hash code''': A unique identifier hash code for the USB device
 +
 
 +
''' Monitored Events '''
 +
 
 +
The trigger monitors the following USB events:
 +
* USB device attached
 +
* USB device detached
 +
* USB accessory attached
 +
* USB accessory detached
 +
 
 +
''' Examples '''
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
USB Device Connect/Disconnect: USB Device Connected</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Notification: USB Device Connected
 +
    [usb_product_name] by [usb_manufacturer_name]
 +
Speak Text: USB device connected</pre>
 +
 
 +
''Notify when any USB device is connected and announce via TTS.''
 +
 
 +
----
 +
 
 +
  <pre class="trigger-style">Triggers
 +
 
 +
USB Device Connect/Disconnect: USB Device Disconnected</pre>
 +
  <pre class="action-style">Actions
 +
 
 +
Popup Message: USB device safely removed</pre>
 +
 
 +
''Show confirmation when a USB device is safely disconnected.''
 +
 
 +
''' Notes '''
 +
 
 +
* This trigger will NOT fire when the Android device itself is connected to a PC or similar as a USB peripheral. It only monitors USB devices connected TO the Android device.
 +
* Works with USB OTG (On-The-Go) connections where the Android device acts as the host.
 +
* Supported devices include USB keyboards, mice, game controllers, USB flash drives, and other USB peripherals.
 +
* USB accessories connected via the accessory protocol are also detected.
 +
* The device information (product name, manufacturer) availability depends on the USB device providing this information.

Revision as of 21:54, 7 January 2026

This trigger will fire when a USB device such as a memory stick or keyboard is connected or disconnected. It monitors for USB peripherals and accessories attached to your Android device.

Options

  • USB Device Connected: Trigger when a USB device is attached to the Android device
  • USB Device Disconnected: Trigger when a USB device is detached from the Android device

Local Variables

This trigger provides the following magic text variables:

  • USB product name: The product name of the connected/disconnected USB device
  • USB manufacturer name: The manufacturer name of the USB device
  • USB device hash code: A unique identifier hash code for the USB device

Monitored Events

The trigger monitors the following USB events:

  • USB device attached
  • USB device detached
  • USB accessory attached
  • USB accessory detached

Examples

Triggers

USB Device Connect/Disconnect: USB Device Connected
Actions

Notification: USB Device Connected
    [usb_product_name] by [usb_manufacturer_name]
Speak Text: USB device connected

Notify when any USB device is connected and announce via TTS.


Triggers

USB Device Connect/Disconnect: USB Device Disconnected
Actions

Popup Message: USB device safely removed

Show confirmation when a USB device is safely disconnected.

Notes

  • This trigger will NOT fire when the Android device itself is connected to a PC or similar as a USB peripheral. It only monitors USB devices connected TO the Android device.
  • Works with USB OTG (On-The-Go) connections where the Android device acts as the host.
  • Supported devices include USB keyboards, mice, game controllers, USB flash drives, and other USB peripherals.
  • USB accessories connected via the accessory protocol are also detected.
  • The device information (product name, manufacturer) availability depends on the USB device providing this information.