HomeHome AutomationEventGhost USB trigger - to launch apps or tasks

EventGhost USB trigger – to launch apps or tasks

A small hack using EventGhost

I had both of my computers wiped recently due to various reasons. It meant that I needed to dabble a bit more in EventGhost to bring all my all automation back. I took this time and opportunity to create an EventGhost USB trigger. Each time I connect my SigmaSport ROX10 cycling computer I have to open the Data Center to download my workout. It was time to automate this. YES, I’m really that lazy when it comes to mundane stuff!

This hack will work for any USB device, across multiple ports and you will be able to trigger any set of actions with EventGhost.

EventGhost: USB trigger

If anything takes me more than a single try and two Google searches, it’s probably worth writing about. To trigger something when a USB device is connected there are a couple of things you have to do.

The benefit of this approach is that regardless of the USB port used, you should be able to recognise the device each time.

You will need 2 macros:

  • USB device connected – identifies the USB device and issues the trigger
  • Device ID – triggers the correct action

USB device trigger

When a USB device is connected to the computer it triggers something like this:

System.DeviceAttached [u'\\\\?\\USB#VID_0483&PID_5740#5&18646f70&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}']

But EventGhost USB trigger that you get moving the event onto the macro is:

System.DeviceAttached

Since I’m not able to identify the USB ID directly I can cheat the EventGhost into reading the ID and posting it as a trigger. To do so – select the Python Command Action and use:

eg.TriggerEvent(eg.event.payload[0][8:25], prefix = eg.event.suffix)
Oh look, it’s a new trigger

Reconnecting the USB device again will produce a new event for us which can be used as USB trigger. This is the EventGhost USB trigger which I’m going to use in the next macro. Note that we have to keep the first macro as well as it will serve as a device identification profile.

Device ID

Just drag and drop it

Now that I have the correct event, I can use it to open up Sigma Data Centre software when the Sigma cycling computer is detected. It’s simple enough, there is an action called Run Application. Open the directory of the software and select the .exe file. 

I can save everything now and next time I connect the cycling computer the EventGhost USB trigger will open the software for me. If you want to add multiple devices, create additional macros for each device, and check the Log for details of newly connected devices.

Conclusion

It’s a simple workaround, but if you have different devices or phones that require particular software to be opened up each time the device is plugged into the system this small hack will save you a couple of seconds. Why not automate it? After all the EvenGhost is constantly running in the background listening to my mobile commands. Any questions? Leave it in this Reddit thread.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.

I wish I had known about the SMLIGHT ZigBee/Thread Coordinators sooner!

0
SMLIGHT coordinators are the perfect choice for anyone just diving into ZigBee. SLZB-06 series is easy to use and comes with future-proofing Thread support.

Sonoff ZigBee Bridge U isn’t what you think!

0
I expected Sonoff ZB Bridge U to be a next gen ZigBee bridge with Matter support. Turns out, there is much more to talk about!

Aqara “Everything” M3 Hub

0
When I started my home automation adventure, the current problem was the number of ecosystems needed to outfit your smart home. Aqara M3 Hub has a long list of protocols to match that!