MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

Auto on/off of the TV (not the Pi)?



  • Re: Auto on/off of the TV (not the Pi)?
    @MechMatt This is nearly the exact setup I would like to implement but without the PIR sensor. I’ve already checked and my Vizio TV is CEC compatible and Ive got a Pi3 with Jessie 8.0. Ideally I’d like to display the MM just from 6-9 am and again from 7-10 pm. Did you make any progress with a script or service that would allow timed display power changes?

    @KirAsh4
    I had already found the link you referenced and in trying to go through it the instructions falter. I’m following the setup listed towards the bottom of this site but when I get down to sudo git clone https://github.com/Pulse-Eight/libcec.git I’m prompted to login to get hub but then just get “remote: repository not found.” Any ideas or advice?



  • Turn the monitor on and off automatically

    To turn the monitor on/off on a daily schedule, grab this script and put it in /home/pi/rpi-hdmi.sh. Next, make it executable:

    chmod +x /home/pi/rpi-hdmi.sh

    Now we’ll need to add a cron entry to call this script at the desired time, so open the cron editor:

    crontab -e

    And add the following lines at the bottom of the file:

    Turn HDMI Off (22:00/10:00pm)

    0 22 * * * /home/pi/rpi-hdmi.sh off

    Turn HDMI On (7:00/7:00am)

    0 7 * * * /home/pi/rpi-hdmi.sh on

    The first number (0) is the minutes and the second number on each of those lines (22 and 7) is the hour in 24 hour time. So in this example, the monitor would turn off at 10:00pm and back on again at 7:00am. Adjust the time for your needs.

    Keep in mind: this does not turn the Raspberry Pi off! It just turns off the monitor, saving energy and hopefully extending the life of your monitor. The Raspberry Pi is still on and running however.


  • Moderator

    @Rtopher said in Auto on/off of the TV (not the Pi)?:

    @KirAsh4
    I had already found the link you referenced and in trying to go through it the instructions falter. I’m following the setup listed towards the bottom of this site but when I get down to sudo git clone https://github.com/Pulse-Eight/libcec.git I’m prompted to login to get hub but then just get “remote: repository not found.” Any ideas or advice?

    What are you logging in as? The 'sudo' command is local to you (your rpi), so that password is your regular user’s password (possibly the 'pi' user, in which case you should not need it as it’s already configured to be allowed to run 'sudo'.) I can run it just fine and it clones that repository as expected.



  • I use a simple command in my crontab:
    0 23 * * * vcgencmd display_power 0
    0 6 * * * vcgencmd display_power 1

    This turns the monitor off at 11pm and back on at 6am.