Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 8 123 ... LastLast
Results 1 to 10 of 75
  1. #1
    Junior Member
    Join Date
    Aug 2020
    Posts
    10

    [piCorePlayer] Turn off USB output when turning off player?

    I am using a Raspberry Pi 4 with piCorePlayer. It is directly connected to the USB input of my speakers. The speakers support auto turn off when the USB goes powerless.

    Is there a possibility like HDMI off for USB when turning off the player run on this Raspberry Pi?

  2. #2
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    4,008
    Depends on which pi you have.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  3. #3
    Senior Member
    Join Date
    Dec 2018
    Location
    The Netherlands
    Posts
    167
    This post on raspberrypi.stackexchange.com refers to a tool called uhubctl that should be able to power on and off USB ports of Raspberry Pi models B+, 2B, 3B, 3B+ and 4B. You may need help to compile this tool for piCorePlayer c.q. Tiny Core Linux.
    | LMS 8.1.2 | Squeezebox Boom | RPi0W + pCP 6.1.0 + HiFiBerry DAC Zero | SqueezeAMP |

  4. #4
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    4,008
    That's correct, it works well on a 4, not as good on the older versions. But I see now you said 4, so that works fine..... BUT
    Please read the notes on that github page. As when turning off the power on the pi ports, it will kill more than one USB port, and in some boards all of the USB ports.

    I've added uhubctl.tcz to our repo. Download it from the extension page

    Paul
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  5. #5
    Junior Member
    Join Date
    Aug 2020
    Posts
    10
    I installed the extension.
    Now I am not sure when exactly the USB ports will be turned off. In the LMS Material Skin I can choose to power off the wanted piCorePlayer. But this does not lead to unpowered USB ports and therefore speakers.
    Stopping and restarting Squeezelite does also not affect it.
    Rebooting or shutting down the piCorePlayer does lead to turned off and then on again speakers.
    But after shutting down I would have to manually reconnect the power supply the next time I want to listen with it.
    My goal would be to have that effect with the LMS Material Skin power button.

  6. #6
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    4,008
    It’s not automatic, you have to learn how to use the program, and write scripts to do what you want.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  7. #7
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    3,987
    Take a look at the very recent thread about turning off/on HDMI and use the script and techniques discussed there as your template.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  8. #8
    Junior Member
    Join Date
    Aug 2020
    Posts
    10
    Got it. Thank you for your replies and for giving direction. I will follow the thread

    https://forums.slimdevices.com/showt...ferrerid=70536

    and try to adjust it for USB.

  9. #9
    Junior Member
    Join Date
    Aug 2020
    Posts
    10
    Following the cited thread, I created the following script file:

    Code:
    #!/bin/sh
    #----------------------------------------------------------------------------------------
    # Script for turning RPi4 USB output on/off when Squeezelite player is turned on/off.
    # This script requires that extension uhubctl.tcz is installed.
    # Enter the path to this "Power On/Off Script" on the pCP Squeezelite Settings page.
    # https://github.com/mvp/uhubctl#raspberry-pi-4b
    #----------------------------------------------------------------------------------------
    # squeezelite -S /home/tc/usb-power-on-off.sh
    # 
    # squeezelite sets $1 to:
    #	0: off
    #	1: on
    #	2: initialising
    #----------------------------------------------------------------------------------------
    
    case $1 in
        0) uhubctl -l 2 -a 0 >/dev/null 2>&1 ;;
        1) uhubctl -l 2 -a 1 >/dev/null 2>&1 ;;
        2) uhubctl -l 2 -a 1 >/dev/null 2>&1 ;;
    esac
    also copied it in the folder /home/tc and linked it in the pCP Squeezelite Settings page under "Power On/Off Script".

    Here is what it does for me:

    "Play" powers up my speakers and plays music.
    "Pause" pauses the music and leads to my speakers being shut down.

    "Power on/off" the player in LMS does not reliably lead to my speakers being power on/off.

    Using the "uhubctl -l 2 -a 0 >/dev/null 2>&1" "/ uhubctl -l 2 -a 1 >/dev/null 2>&1" command loged in my piCorePlayer via SSH always works as expected.

    1. I am fine with "Play/Pause" causing my speakers to turn on/off but I expected this solution to work with "Power on/off" in LMS.
    2. "2: initialising": do I really need that line in my script or can I leave it out?
    Last edited by sisiko; 2020-08-16 at 10:34.

  10. #10
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    4,008
    Yes, you can leave out initializing. Make sure you are not using the -C option on the squeezelite page.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •