Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 3 123 LastLast
Results 1 to 10 of 23
  1. #1
    Member
    Join Date
    Dec 2018
    Location
    The Netherlands
    Posts
    88

    [piCorePlayer] Switch off HDMI output when turning off player?

    Hi all,

    I am using piCorePlayer 6.1.0 on a Raspberry Pi ZeroW. I installed Jivelite for displaying the "Now Playing" screen on a monitor or TV via HDMI, and control piCorePlayer via an Android App or via a RF (USB) remote control.

    It appears that the HDMI output of my ZeroW stays active when I turn off the player, also when the screensaver for the "player off state" is set to Display Off (via Jivelite Settings => Screen => Screensavers => When off => Display Off). When I turn Off the player via the Android App or the Remote Control, the screen goes black, but the HDMI output stays active, meaning that also the attached monitor stays turned on. In fact I don't see a difference between screen saver settings "Blank Screen" and "Display Off".

    => Can anybody tell it is possible to switch off the HDMI output when turning off the player? If so, how?

    PS1: I know that turning off the HDMI output gives only a small reduction in current consumption of the Raspberry Pi. My main concern is the power consumption of the attached monitor.
    PS2: When I set HDMI power to "off" on the pCP Tweaks page, then the HDMI output is switched off at the end of the boot process, and the attached monitor goes into standby mode. This shows that the HDMI output of the ZeroW can be switched off, only it does not happen when turning off the player.
    | LMS 8.0 | Squeezebox Boom | RPi0W + pCP 6.1.0 + HiFiBerry DAC Zero | SqueezeAMP |

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    I just had a look at the "tweaks" in pCP and (simplified) it installs
    rpi-vc.tcz (if not already installed)
    and then uses
    tvservice -o
    to turn off the HDMI
    however, while that works fine when the "on" process requires a reboot it is probably not OK for the situation you describe.

    You probably need to run
    vcgencmd display_power 0
    and then
    vcgencmd display_power 1
    to turn it back on again when the player is turned on again.

    (I have not checked but rpi-vc.tcz might contain vcgencmd)

    So - try that from command line (once the tcz is installed) and if it does what you want then the next thing to work out is how to launch it on the power off/power on operation of the player ...

    Edit:
    see https://www.raspberrypi.org/document...ns/vcgencmd.md for more options (e.g. if someone is trying to do this on RPi4 then changes might be needed because of its dual HDMI)
    Last edited by Paul Webster; 2020-08-13 at 02:07.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  3. #3
    Member
    Join Date
    Dec 2018
    Location
    The Netherlands
    Posts
    88
    Thanks Paul for your help.

    It appears that extension rpi-vc.tcz is uninstalled when HDMI power is set to "on" on the Tweaks page:
    rpi-vc.tcz is in the list of uninstalled extensions under Main Page => Extensions.
    This might explain why the HDMI output stays turned on when turning off the player.

    When I type "tvservice -o" I get:
    -sh: tvservice: not found
    Also when I type "vcgencmd display_power 0" I get:
    -sh vcgencmd: not found

    I don't see an option to install uninstalled extensions on the Extensions page.
    Do you know how to install rpi-vc.tcz without setting HDMI power to "off" on the Tweaks page?

    PS: I installed rpi-vc.tcz by setting HDMI power to "off" on the Tweaks page.
    After reboot, the HDMI output is turned off and the connected monitor goes in standby mode (as expected).
    When I then type "vcgencmd display_power 1" I get:
    VCHI initialization failed
    Last edited by CJS; 2020-08-13 at 02:45.
    | LMS 8.0 | Squeezebox Boom | RPi0W + pCP 6.1.0 + HiFiBerry DAC Zero | SqueezeAMP |

  4. #4
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    One of the pCP team probably needed for a proper solution.
    However, you might be able to get HDMI working again by exiting the config.txt (to enable HDMI if needed) and pcp.cfg (to make it think that HDMI is enabled and hopefully not uninstall the .tcz because you would not be doing it through tweaks.
    Then
    pcp bu
    To get the changes saved...
    then reboot

    Perhaps vcgencmd will then work because HDMI is enabled.

    However, making a faulty move and backing up could result in a broken system so having a full backup of the SD card or being prepared to reinstall completely would be good.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  5. #5
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    Looks like "VCHI initialization failed" can happen when it cannot access /dev/vchiq
    I see that /dev/vchiq has only root access (on my pCP at least) so guidance elsewhere to put the user into the "video" group might not work so try
    sudo vcgencmd
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  6. #6
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    3,365
    vcgencmd needs to run with root access. Pretty much everything in pCP is running under root anyway. Which is why we don't have a ton of udev rules to change device permissions.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  7. #7
    Member
    Join Date
    Dec 2018
    Location
    The Netherlands
    Posts
    88
    Quote Originally Posted by paul- View Post
    vcgencmd needs to run with root access. Pretty much everything in pCP is running under root anyway. Which is why we don't have a ton of udev rules to change device permissions.
    Hi Paul and paul-,

    Thanks for your help. I can confirm that when I run vcgencmd as root I can turn on and off the HDMI output.

    This is what I did. First I installed rpi-vc.tcz by setting HDMI power to "off" on the Tweaks page.
    After reboot, the HDMI output is turned off at the end of the boot sequence and the connected monitor goes in standby mode.

    When I then type:
    "sudo vcgencmd display_power 1"
    the HDMI output is turned on, and the Jivelite GUI is displayed on the connected monitor
    And when I then type:
    "sudo vcgencmd display_power 0"
    the HDMI output is turned off, and the connected monitor goes in standby mode.
    And then typing:
    "sudo vcgencmd display_power 1"
    turns on the HDMI output again.

    When I then use the power button on the Remote Control to turn off pCP, the audio stops and the screen turns black, but the monitor does not go in standby mode, indicating that the HDMI output stays ON.

    So now I need to figure out if I can issue command "sudo vcgencmd display_power 1" at the end of the boot sequence (and when turning on pCP after the player was turned off), and issue command "sudo vcgencmd display_power 0" after turning off the player. I will try if I can get this to work on one of the coming days. And of course suggestions on how to accomplish this are welcome.
    | LMS 8.0 | Squeezebox Boom | RPi0W + pCP 6.1.0 + HiFiBerry DAC Zero | SqueezeAMP |

  8. #8
    Senior Member
    Join Date
    Apr 2005
    Location
    UK/London
    Posts
    2,919
    You could set up a cron job to run once a minute to check the pCP player status and if changed from last check then run the command.
    Paul Webster
    http://dabdig.blogspot.com
    Author of "Now Playing" plugins covering Radio France (FIP etc), KCRW, Supla Finland, ABC Australia, CBC/Radio-Canada and RTE Ireland

  9. #9
    Senior Member paul-'s Avatar
    Join Date
    Jan 2013
    Posts
    3,365
    You can use the scripting method in squeezelite to call a script when the LMS power is toggled. Look at the -S option.
    piCorePlayer a small player for the Raspberry Pi in RAM.
    Homepage: https://www.picoreplayer.org

    Please donate if you like the piCorePlayer

  10. #10
    Member
    Join Date
    Dec 2018
    Location
    The Netherlands
    Posts
    88
    Quote Originally Posted by paul- View Post
    You can use the scripting method in squeezelite to call a script when the LMS power is toggled. Look at the -S option.
    Thanks for the golden tip! Turning on/off the RPi HDMI output when turning on/off the pCP squeezelite player with my Remote Control or Android App is now working!

    Based on your hint I created a script called "hdmi-power-on-off.sh" (I derived it from /home/tc/powerscript.sh), placed it in folder /home/tc, and entered the path to the script in the "Power On/Off script" field on the pCP Squeezelite Settings page. After saving settings, the HDMI output is now turned on/off when turning on/off the squeezelite player. When I turn off the pCP squeezelite player with my Remote Control the monitor that is connected to the HDMI output now goes in standby mode, indicating that the HDMI output is indeed switched off. This is exactly the behavior that I was looking for.

    Content of script hdmi-power-on-off.sh, placed in folder /home/tc, is as follows:
    Code:
    #!/bin/sh
    #----------------------------------------------------------------------------------------
    # Script for turning RPi HDMI output on/off when Squeezelite player is turned on/off.
    # This script requires that extension rpi-vc.tcz is installed.
    # Extension rpi-vc.tcz is installed by selecting HDMI power off on the pCP Tweaks page.
    # Enter the path to this "Power On/Off Script" on the pCP Squeezelite Settings page.
    #----------------------------------------------------------------------------------------
    # squeezelite -S /home/tc/hdmi-power-on-off.sh
    # 
    # squeezelite sets $1 to:
    #	0: off
    #	1: on
    #	2: initialising
    #----------------------------------------------------------------------------------------
    # Version: 0.1 2020-08-14 CJS
    
    case $1 in
        0)
        sudo vcgencmd display_power 0
        ;;
        1)
        sudo vcgencmd display_power 1
        ;;
        2)
        sudo vcgencmd display_power 1
        ;;
    esac
    The picture below shows where the path to the script is entered on the pCP Squeezelite Settings page:

    Name:  hdmi-power-on-off_squeezelite.png
Views: 102
Size:  14.5 KB

    Kind regards,
    CJS
    | LMS 8.0 | Squeezebox Boom | RPi0W + pCP 6.1.0 + HiFiBerry DAC Zero | SqueezeAMP |

Posting Permissions

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