Skip to content

Instantly share code, notes, and snippets.

@xobs
Last active February 6, 2026 00:07
Show Gist options
  • Select an option

  • Save xobs/800a5b981a0a00751f3808f726bc8ad4 to your computer and use it in GitHub Desktop.

Select an option

Save xobs/800a5b981a0a00751f3808f726bc8ad4 to your computer and use it in GitHub Desktop.
Script to turn LEDs off on a smart hub -- run with: `cargo +nightly -Zscript led_off.rs`
#!/usr/bin/env cargo
---
package.edition = "2024"
dependencies.nusb = { version = "0.2.1" }
---
use nusb::transfer::{ControlOut, ControlType, Recipient};
use nusb::MaybeFuture;
use std::time::Duration;
fn main() {
for dev in nusb::list_devices().wait().unwrap() {
if dev.vendor_id() != 0x05e3 || dev.product_id() != 0x0610 || dev.class() != 0x09 {
continue;
}
let mut s = format!("{}", dev.bus_id());
for port in dev.port_chain() {
s.push_str(&format!("/{port}"));
}
println!(
"Disabling LEDs on {s} {} {} - {}",
dev.serial_number().unwrap_or("<no serial>"),
dev.manufacturer_string().unwrap_or("<no manufacturer>"),
dev.product_string().unwrap_or("<no product>")
);
let Ok(dev) = dev
.open()
.wait()
.inspect_err(|e| eprintln!("Couldn't open: {e}"))
else {
continue;
};
for port in 1..=4 {
let off = ControlOut {
control_type: ControlType::Class,
recipient: Recipient::Other,
request: 3, // SET_FEATURE
value: 22, // PORT_INDICATOR,
index: 0x0300 | port as u16, // Turn off (3) LED on the specified port
data: &[],
};
if let Err(e) = dev.control_out(off, Duration::from_secs(5)).wait() {
eprintln!("Unable to turn LEDs off: {e}");
continue;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment