companion icon indicating copy to clipboard operation
companion copied to clipboard

CompanionPI: Power down streamdeck on schedule

Open BrianGilbert opened this issue 3 years ago • 1 comments

Describe the feature What I'm looking for is a way to power down the streamdeck without having to unplug the USB cable, ideally I could schedule this behaviour using cron, and have the ability to override it while disabled to enable it if required.

I found the following that may assist with doing this:

  • https://github.com/mvp/uhubctl
  • https://github.com/mvp/uhubctl#raspberry-pi-4b

ideally scripts will also rescan USB within companion after re-enabling USB

Usecases

  • Extend life of the streamdeck
  • Save a small amount of power
  • Reduce light pollution in room

BrianGilbert avatar Jul 12 '21 19:07 BrianGilbert

To install uhubctl:

git clone https://github.com/mvp/uhubctl
cd uhubctl
make
sudo make install
cd ../
rm -rf ./uhubctl

To disable power to port 4 of the inbuilt USB hub:

sudo uhubctl -l 1-1 -p 4 -a 0 -r 10

To enable power to port 4 of the inbuilt USB hub:

sudo uhubctl -l 1-1 -p 4 -a 1

To schedule this:

sudo crontab -e

Add the following lines to stop Streamdeck plugged into port 4 at 9pm and start it at 7am:

# Power down StreamDeck
0 21 * * * sudo uhubctl -l 1-1 -p 4 -a 0 -r 10 >/dev/null 2>&1

# Power up StreamDeck
0 7 * * * sudo uhubctl -l 1-1 -p 4 -a 1 >/dev/null 2>&1

# Rehup Companion so control surface is activated
2 7 * * * sudo systemctl restart companion >/dev/null 2>&1

todo: make scripts to start and stop so that I can do it when I want as well. (also check if usb power is off before rehupping companion)

BrianGilbert avatar Jul 13 '21 19:07 BrianGilbert