From ba9428558adc70ed8cb3cdcea1723358ead23741 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 6 May 2024 07:56:42 -0400 Subject: [PATCH] docs: add uhubctl documentation Signed-off-by: Eric Callahan --- docs/changelog.md | 1 + docs/configuration.md | 57 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index f45e555..b6e9c3e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog]. - **history**: Added support for auxiliary history fields - **spoolman**: Report spool ids set during a print in history auxiliary data - **sensor**: Added support for history fields reported in auxiliary data +- **power**: Added support for `uhubctl` devices ### Fixed diff --git a/docs/configuration.md b/docs/configuration.md index 6645a16..2d10df7 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -675,11 +675,11 @@ The following configuration options are available for all power device types: type: # The type of device. Can be either gpio, klipper_device, rf, # tplink_smartplug, tasmota, shelly, homeseer, homeassistant, loxonev1, -# smartthings, mqtt or hue. +# smartthings, mqtt, hue, http or uhubctl. # This parameter must be provided. initial_state: off # The state the power device should be initialized to. May be on or -# off. When this option is not specifed no initial state will be set. +# off. When this option is not specified no initial state will be set. off_when_shutdown: False # If set to True the device will be powered off when Klipper enters # the "shutdown" state. This option applies to all device types. @@ -1343,6 +1343,59 @@ device_type: light ``` +#### USB (uhubctl) devices + +Support for toggling USB powered devices via [uhubctl](https://github.com/mvp/uhubctl). + +!!! Note + The host machine must have `uhubctl` installed as a prerequisite. In addition, + the required [udev rules](https://github.com/mvp/uhubctl#linux-usb-permissions) + must be installed on the host to give Moonraker permission to toggle hub + power without sudo. + +```ini +location: +# Device location of the USB Hub connected to the device to control. The +# location corresponds to the "-l" option of "uhubctl". This parameter +# must be provided. +port: +# Port of the USB device to control. The port corresponds to the "-p" +# option of "ububctl". This parameter must be provided + +``` + +!!! Tip + The `uhubctl` software can be used to list all compatible hubs on the + system by simply executing `uhubctl` with no arguments. The following + is example output from a Raspberry Pi 3B+: + + ``` + Current status for hub 1-1.1 [0424:2514, USB 2.00, 3 ports, ppps] + Port 1: 0503 power highspeed enable connect [0424:7800] + Port 2: 0100 power + Port 3: 0100 power + Current status for hub 1-1 [0424:2514, USB 2.00, 4 ports, ppps] + Port 1: 0503 power highspeed enable connect [0424:2514, USB 2.00, 3 ports, ppps] + Port 2: 0100 power + Port 3: 0103 power enable connect [1d50:614e Klipper rp2040 45503571290B1068] + Port 4: 0100 power + Current status for hub 1 [1d6b:0002 Linux 6.6.28+rpt-rpi-v7 dwc_otg_hcd DWC OTG Controller 3f980000.usb, USB 2.00, 1 ports, ppps] + Port 1: 0503 power highspeed enable connect [0424:2514, USB 2.00, 4 ports, ppps] + ``` + +##### Example + +```ini +# moonraker.confg + +# Example for controlling a device connected to a Raspberry Pi 3B+. +# Location 1-1 Port 2 controls power for all 4 exposed ports. +[power my_usb_dev] +type: uhubctl +location: 1-1 +port: 2 +``` + #### Generic HTTP Devices Support for configurable HTTP switches. This device type may be used when