How to trigger automation while disconnecting to a usb device?

Hello. My homeassistant is installing on a synology nas with docker. And my gamepad is connected to that nas by USB for charging.

So I’d like to create an automation that if I unplug the gamepad (that means I wanna playing games), turn on my pc through WOL and swtich on the TV.

I’ve done the WOL and TV control before, but how to do trigger them while the gamepad is disconnecting from the nas?

Is there an integration for your NAS that supports telling Home Assistant when a device disconnects from USB?

No I haven’t discovered such an intergration for the synology’s OS that share the usb device info.

But thanks for your hint I’m thinking about if

  1. pass the usb interface through the docker container and let homeassistant to access
  2. so that USB Discovery integration can effect.
  3. And then get an integration like ‘USB Disconnect’ from somewhere, which effect same as USB Discovery but when disconnecting.
  4. OK know its done!

If so, now the question can become

  1. Can a usb interface pass to a container? It a question about docker not HomeAssistant and I’m gonna serch it.
  2. is there such an integration for HomeAssistant itself to monitor USB device disconnecting?

Yes, you can pass USB ports to Docker containers. But does your NAS let Docker have such access to the hardware?

Check this for how to give HA visibility into USB. Although I’m not sure if that applies only to HA Supervised.

Get a push button that will connect to HA, store it at your NAS, press it when you grab your controller.

If you are running HA in privileged mode in Docker you should have access to all the USB devices. You should be able write a shell script that reports whether the device is attached. Look at the output of lsusb and run it through grep. If you need help post the output and I can help.