MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. wi_brewer
    3. Best
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    W
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 5
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: Turning monitor on/off when not in use.

      Thanks for the input, @cruunnerr and @martinkooij.

      I ended up going with @cruunnerr’s approach as it required fewer changes to my existing setup.

      Here is what I did:

      1. Created a file that lists the devices and their IPs that we want to evaluate. Filename: “devices”.
      myphone,192.168.0.200
      mywatch,192.168.0.201
      wifephone,192.168.0.202
      wifewatch,192.168.0.203
      
      1. Created a perl script, “ping.pl”, that pings the devices listed in the file. If it gets a response it will write the results to a file named “ping_results”.
      #!/usr/bin/perl
      use Net::Ping;
      open(INFILE, ";
      close(INFILE);
      #open(OUTFILE, ">", "ping_results") or die("unable to write output: $!");
      chomp(@ip_array);
      $p = Net::Ping->new();
      foreach(@ip_array)
        {
         if($_ =~ /\d+.\d+.\d+.\d+/)
            {
              if($p->ping($&))
                {
                  open(OUTFILE, ">", "ping_results") or die("unable to write output: $!");
                  print OUTFILE ("$`is responding to ping.\n");
                  close(OUTFILE);
                }
            }
        }
      
      1. Added a crontab job to run the perl script at 04:55.
      # m h  dom mon dow   command
      # Execute Perl Script to check for devices
      55 4 * * * perl /home/pi/ping.pl
      
      1. Created a shell script, “rpi-hdmi-on.sh” that will check to see if “ping_results” exists. If it does it will turn the monitor on and then delete the “ping_results” file. Added a crontab job to execute this script at 05:00.
      if [ -e ping_results ]
      then
              vcgencmd display_power 1 >/dev/null
              rm -f /home/pi/ping_results
      fi
      
      # m h  dom mon dow   command
      # Turn HDMI On (05:00/5:00am)
      0 5 * * * /home/pi/rpi-hdmi-on.sh
      
      1. Created a shell script, “rpi-hdmi-off.sh” that will turn the monitor off. Added a crontab job to execute this script at 21:30.
      vcgencmd display_power 0 >/dev/null
      
      # m h  dom mon dow   command
      # Turn HDMI Off (21:30/9:30pm)
      30 21 * * * /home/pi/rpi-hdmi-off.sh
      

      I’ve done some testing and it seems to be working well.

      posted in Troubleshooting
      W
      wi_brewer
    • 1 / 1