uhubctl posted.
Announcement
Collapse
No announcement yet.
[piCorePlayer] Turn off USB output when turning off player?
Collapse
X
-
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
Originally posted by paul- View Postuhubctl posted.
https://github.com/mvp/uhubctl#raspberry-pi-b2b3b
is incorrect. It states that all the USB ports on the Pi3B are linked together and controlled by Port 2. In fact they are controlled separately and turning off port 2 does not turn off ports 2-5. Turning off port 4 works for me.Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by slartibartfast View PostThanks for posting it Paul. I was about to post that I couldn't get it working on my Pi 3B but it turns out that the info posted here
https://github.com/mvp/uhubctl#raspberry-pi-b2b3b
is incorrect. It states that all the USB ports on the Pi3B are linked together and controlled by Port 2. In fact they are controlled separately and turning off port 2 does not turn off ports 2-5. Turning off port 4 works for me.
-S /home/tc/usb-power-on-off.sh
in Various Options on the Squeezelite settings page. My script file is
Code:#!/bin/sh #---------------------------------------------------------------------------------------- # Script for turning RPi3 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-b2b3b #---------------------------------------------------------------------------------------- # squeezelite -S /home/tc/usb-power-on-off.sh # # squeezelite sets $1 to: # 0: off # 1: on #---------------------------------------------------------------------------------------- case $1 in 0) uhubctl -l 1-1 -p 4 -a 0 >/dev/null 2>&1 ;; 1) uhubctl -l 1-1 -p 4 -a 1 >/dev/null 2>&1 ;; esac
Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Likely need to reference the full path to the binary.
/usr/local/sbin/uhubctlpiCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
Comment
-
Originally posted by sisiko View PostFollowing 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. # [url]https://github.com/mvp/uhubctl#raspberry-pi-4b[/url] #---------------------------------------------------------------------------------------- # 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
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.
- 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: initialising": do I really need that line in my script or can I leave it out?
Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by paul- View PostLikely need to reference the full path to the binary.
/usr/local/sbin/uhubctl
Code:#!/bin/sh #---------------------------------------------------------------------------------------- # Script for turning RPi3 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-b2b3b #---------------------------------------------------------------------------------------- # squeezelite -S /home/tc/usb-power-on-off.sh # # squeezelite sets $1 to: # 0: off # 1: on #---------------------------------------------------------------------------------------- case $1 in 0) /usr/local/sbin/uhubctl -l 1-1 -p 4 -a 0 >/dev/null 2>&1 ;; 1) /usr/local/sbin/uhubctl -l 1-1 -p 4 -a 1 >/dev/null 2>&1 ;; esac
Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by paul- View PostLikely need to reference the full path to the binary.
/usr/local/sbin/uhubctlLiving Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by slartibartfast View PostI also tried the built in "powerscript.sh" which sends the $1 state to an ssh terminal and that doesn't work either. Am I wrong in expecting that toggling the power of piCorePlayer in Material skin or the Default skin should change the state of $1 and display it in the terminal?
echo "All Arguments values:" [email protected] >/tmp/allargs.txt
Comment
-
Originally posted by bpa View PostJust in case the arg num is wrong you should dump all args values into a file - something like
echo "All Arguments values:" [email protected] >/tmp/allargs.txt
Sent from my Pixel 3a using TapatalkLiving Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by bpa View PostJust in case the arg num is wrong you should dump all args values into a file - something like
echo "All Arguments values:" [email protected] >/tmp/allargs.txt
Sent from my Pixel 3a using TapatalkLiving Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
My suggestion is in the script.
The following is my version which just creates lots of output to shows which parts of script are executed.
Squeezelite V1.9.7-1283 was tested on a Rasbian Buster
Squeezelite is standard Ralphy and has GPIO build option.
Run from command line with "-S /home/pi/myscript.sh"
Code:#!/bin/sh #---------------------------------------------------------------------------------------- # Script for turning RPi3 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-b2b3b #---------------------------------------------------------------------------------------- # squeezelite -S /home/tc/usb-power-on-off.sh # # squeezelite sets $1 to: # 0: off # 1: on #---------------------------------------------------------------------------------------- NOW=$(date +"%m-%d-%Y %T") echo "--- $NOW ---" >>/tmp/powerlog.txt echo "Args: " "[email protected]" >>/tmp/powerlog.txt case $1 in 0) echo "Arg dollar 1 value 0 " >>/tmp/powerlog.txt ;; 1) echo "Arg dollar 2 value 1 " >>/tmp/powerlog.txt ;; esac echo "---- End run ---- " >>/tmp/powerlog.txt
Code:--- 11-15-2020 11:49:12 --- Args: 0 Arg dollar 1 value 0 ---- End run ---- --- 11-15-2020 11:49:12 --- Args: 1 Arg dollar 2 value 1 ---- End run ---- --- 11-15-2020 11:49:13 --- Args: 0 Arg dollar 1 value 0 ---- End run ---- --- 11-15-2020 11:49:13 --- Args: 1 Arg dollar 2 value 1 ---- End run ----
Comment
-
Originally posted by bpa View PostMy suggestion is in the script.
The following is my version which just creates lots of output to shows which parts of script are executed.
Squeezelite V1.9.7-1283 was tested on a Rasbian Buster
Squeezelite is standard Ralphy and has GPIO build option.
Run from command line with "-S /home/pi/myscript.sh"
Code:#!/bin/sh #---------------------------------------------------------------------------------------- # Script for turning RPi3 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-b2b3b #---------------------------------------------------------------------------------------- # squeezelite -S /home/tc/usb-power-on-off.sh # # squeezelite sets $1 to: # 0: off # 1: on #---------------------------------------------------------------------------------------- NOW=$(date +"%m-%d-%Y %T") echo "--- $NOW ---" >>/tmp/powerlog.txt echo "Args: " "[email protected]" >>/tmp/powerlog.txt case $1 in 0) echo "Arg dollar 1 value 0 " >>/tmp/powerlog.txt ;; 1) echo "Arg dollar 2 value 1 " >>/tmp/powerlog.txt ;; esac echo "---- End run ---- " >>/tmp/powerlog.txt
Code:--- 11-15-2020 11:49:12 --- Args: 0 Arg dollar 1 value 0 ---- End run ---- --- 11-15-2020 11:49:12 --- Args: 1 Arg dollar 2 value 1 ---- End run ---- --- 11-15-2020 11:49:13 --- Args: 0 Arg dollar 1 value 0 ---- End run ---- --- 11-15-2020 11:49:13 --- Args: 1 Arg dollar 2 value 1 ---- End run ----
Running -S /home/tc/myscript.sh doesn't work from command line. I see "-sh: -S: not found"
Adding it as a script in pCP also doesn't seem to do anything. Maybe my scripts aren't running for some reason.Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by slartibartfast View PostI am using squeezelite v1.97-1282-pCP
Running -S /home/tc/myscript.sh doesn't work from command line. I see "-sh: -S: not found"
Adding it as a script in pCP also doesn't seem to do anything. Maybe my scripts aren't running for some reason.
The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/bin/sh"
There is a pcp extension called bash.tcz whic may provide "/bin/bash "which may also then create a link to "/bin/sh"
For example if I change the first line on my system to "#!/bin/badshell" I get the following message
Code:sh: 1: /home/pi/myscript.sh: not found
Comment
-
Originally posted by bpa View PostYou don't show your command line
The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/usr/sh"
There is a pcp extension called bash.tcz whic may provide "/usr/bash "which may also then create a link to "/usr/sh"
For example if I change the first line on my system to "!/usr/badshell" I get the following message
Code:sh: 1: /home/pi/myscript.sh: not found
Sent from my Pixel 3a using TapatalkLiving Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
-
Originally posted by bpa View PostYou don't show your command line
The first line indicates which shell to use. IIRC pcp doesn't have a shell it uses busybox - so there may be no "/usr/sh"
There is a pcp extension called bash.tcz whic may provide "/usr/bash "which may also then create a link to "/usr/sh"
For example if I change the first line on my system to "!/usr/badshell" I get the following message
Code:sh: 1: /home/pi/myscript.sh: not found
/home/tc/my script.sh
without the -S
I get
/home/tc/my script.sh: line 17: syntax error: unexpected word (expecting "in")
Sent from my Pixel 3a using TapatalkLiving Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
Bedroom: Radio
Bathroom: Radio
Comment
Comment