Page 1 of 1

USB Trigger

Posted: 19 Dec 2013 17:57
by mick64
Would it be possible to add a USB trigger? I would like to be able trigger actions when I connect to my PC or connect a USB device.

To connect to a USB device, an OTG (on the go) cable is required. Is it possible to detect when this is plugged in?

Edit: Martin, Sorry I did not see your post stating that there is no way of directly detecting a USB connection. However, I am more interested in detecting when the OTG cable is plugged in. I believe this works in a similar way to how docking is detected. When the device is docked it detects a resistance between pins 4 and 5 on the USB connector. With the OTG cable, pins 4 and 5 are shorted together. I am hoping there is a way to detect this so that I can trigger a number of actions when my USB DAC is plugged in. Thank you.

Edit: Hi again, I've been looking at other automation apps and have found that it is possible to detect certain USB devices, but there are limitations. I still think this would be a good addition to the list of triggers, even if it wasn't guaranteed to work.

I have also experimented with my own OTG cable, and have found that when it is inserted, it briefly notifies you of a USB connection even with nothing connected to it. I am hopeful that this means it is possible to detect the OTG cable and create a trigger for it.

Re: USB Trigger

Posted: 21 Dec 2013 08:29
by Martin
I checked the documentation and it seems that it might be possible to detect some events (Android 3.1+) but the documentation is not very clear. I add it to the todo list but there might be limitations.

Perhaps you can also detect the notification with a trigger Notification on Statusbar Displayed.

Re: USB Trigger

Posted: 21 Dec 2013 10:10
by mick64
Hi Martin, thank you for looking into this.

As for the USB connected notification, could you give me some help with this trigger. I am not sure what package to select, or if anything else is required. Thank you.

Re: USB Trigger

Posted: 21 Dec 2013 12:09
by Martin
You can set the package name of the trigger to * to match all packages and then add an action Notification on Screen: {package_name}.
Alternatively you could also add a condition Debug Dialog to the flow to show all variables and the corresponding values when the flow is executed.

Regards,
Martin

Re: USB Trigger

Posted: 21 Dec 2013 12:46
by mick64
Thanks Martin, that was very helpful. The package name is 'android'. hopefully I can use this in conjunction with a condition to trigger the actions I require.

I love this app! Keep up the good work! Hope to see the USB trigger in the near future. Thanks again.