5

I bought a USB lamp that I want to turn ON/OFF using commands (my purpose is to setup some CRON jobs to turn it ON at certain times).

I researched several answers, but none worked.

I tried outputting to /sys/bus/usb/drivers/usb/unbind, /sys/bus/usb/devices/usb1/power/level, the uhubctl tool, using all USB ports including ports in a USB Hub, etc. Nothing worked.

The lamp is a dumb device, it simply gets turned ON when plugging it to the port.

My PC is MouseComputer Co.,Ltd. MB-R500.

The lamp is this one.

lsb_release -a

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

sudo lsusb
Bus 002 Device 004: ID 2109:0813 VIA Labs, Inc. VL813 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 123: ID 13d3:56af IMC Networks USB2.0 HD UVC WebCam
Bus 001 Device 121: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 119: ID 2808:9338 Focal-systems.Corp FT9201Fingerprint.̚
Bus 001 Device 054: ID 19d2:1405 ZTE WCDMA Technologies MSM ZTE Technologies MSM
Bus 001 Device 053: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 052: ID 046d:c548 Logitech, Inc. USB Receiver
Bus 001 Device 051: ID 2109:2813 VIA Labs, Inc. VL813 Hub
Bus 001 Device 125: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
sudo uhubctl
Current status for hub 2-2 [2109:0813 VIA Labs, Inc. USB3.0 Hub, USB 3.00, 4 ports, ppps]
  Port 1: 02a0 power 5gbps Rx.Detect
  Port 2: 02a0 power 5gbps Rx.Detect
  Port 3: 02a0 power 5gbps Rx.Detect
  Port 4: 02a0 power 5gbps Rx.Detect
Current status for hub 1-2 [2109:2813 VIA Labs, Inc. USB2.0 Hub, USB 2.10, 4 ports, ppps]
  Port 1: 0100 power
  Port 2: 0103 power enable connect [046d:c548 Logitech USB Receiver]
  Port 3: 0103 power enable connect [046d:c52b Logitech USB Receiver]
  Port 4: 0503 power highspeed enable connect [19d2:1405 ZTE,Incorporated ZTE Technologies MSM MF9751ZTED000000]

This is a fragment of lsusb -v output, then searched for Anker which is the name of my HUB.

Bus 001 Device 068: ID 291a:8365 Anker                   Anker USB-C Hub Device
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass           17
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x291a
  idProduct          0x8365
  bcdDevice            0.01
  iManufacturer           1 Anker
  iProduct                2 Anker USB-C Hub Device
  iSerial                 3 0000000000000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0012
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3 0000000000000001
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass        17
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              3 0000000000000001
  • Depending on the hardware, you may not be able to disable the power to the port, but only whether the OS is permitted to use a connected device. Could you [edit] your question to include as much detail as possible regarding your computer (make/model/whether lamp is in USB hub or direct/etc.) as well as the output of lsusb? This may make it possible to identify whether you can control power to a specific port/device – matigo Sep 16 '23 at 14:24
  • @matigo I updated the question with some information. – Chris Vilches Sep 16 '23 at 15:47
  • 1
    Also I just realized that the lamp doesn't appear in the lsusb output. It seems it does nothing to the system other than get power. Not sure though. – Chris Vilches Sep 16 '23 at 15:50
  • Your best option may be to use a USB hub that supports port power switching as provided in This answer and Another answer – stumblebee Sep 17 '23 at 19:58
  • I have a tiny USB lamp. I tested it by entering journalctl -f before plugging it in and plugging it out. Nothing is sensed by the kernel. So my guess is the same as yours @ChrisVilches – FedKad Sep 18 '23 at 11:22

1 Answers1

3

I was able to turn it off. The solution:

  1. Buy a USB HUB that supports port power switching. Most don't, so research well before buying.
  2. Use the uhubctl tool (install it with sudo apt install uhubctl).

The HUB I bought is this one (Sugoi HUB by System Talks, model: USB2-HUB4X-BK). I'm not sure if it's still being produced, but there are other ones that work (here's a non-exhaustive list of supported hubs).

In my case, I use this command (read the documentation) to toggle ON/OFF:

sudo uhubctl -l 1-1 -p 1 -a toggle

Obviously the numbers will be different for another setup.

mvp
  • 178
  • 1
  • 6