raven22;341317 Wrote: 
> Let me explain my request. In the evening i like to go to sleep with my
> boom playing songs via squeezecenter. Then during the night the server
> can be shutdown. However in the morning with the alarm set you don't
> get music since the server is not awakened fast enough via WOL. So if
> it were possible to shutdown and switch over to squeezenetwork every
> night at a certain time this would solve the problem because you can
> get awakened by a favorite radiostation in the morning.
A discrete shutdown time function might be a feature that could make it
into a future version.  But many folks have jumped off this particular
bridge before now.  Again, I would direct you to Max Spicer's
shutdown.pl script: http://www.thespicers.net/shutdown.pl.  Small
modifications to that script will get you what you want. Something
along the lines of:
Code:
--------------------
    
  #!/usr/bin/perl -w
  #
  # Example crontab entry:
  # Shutdown every 30 minutes from 1am to 5:30am
  # 0,30 1-5 * * * /usr/local/sbin/shutdown2sn.pl
  
  use strict;
  use IO::Socket;
  use POSIX qw(strftime);
  
  # Print debug output if true.  Higher values increase verbosity.
  my $debug = 9;
  
  # Turnoff players..
  my $turnoff = 1;
  
  # Fix up the $PlayerToSwitchToSN MAC address to match the real MAC address of 
the
  # player you want to switch to SN, as found at Settings->Status in
  # the SC web ui.
  
  my $PlayerToSwitchToSN = "00:04:20:06:29:30";
  
  
  # Change server details below if necessary
  my $socket = IO::Socket::INET->new (PeerAddr => '127.0.0.1',
  PeerPort => 9090,
  Proto    => 'tcp',
  Type     => SOCK_STREAM)
  or die 'Couldn\'t connect to server';
  
  # Get the number of players
  my $playerCount = sendAndReceive('player count ?');
  $debug && print "$playerCount players found\n";
  
  # Interrogate current state of each player
  my $playersPlaying = 0;
  my @playerIds;
  for (my $i = 0; $i <  $playerCount; $i++) {
  # Get the player's internal id and store for future reference
  $playerIds[$i] = sendAndReceive("player id $i ?");
  $debug && print "Player $i has ID $playerIds[$i]\n";
  my $playerMode = sendAndReceive("$playerIds[$i] mode ?"); 
  $debug && print "Player ${i}'s mode is $playerMode\n";
  if ($playerMode eq 'play') {
  $playersPlaying++;
  }
  }
  
  $debug && print "$playersPlaying/$playerCount players playing\n";
  if (!$playersPlaying) {
  $debug && print "Shutting down to squeezenetwork..\n";
  my $response = sendAndReceive("srvrpowerctrl shutdown2SN 
Switching_to_SqueezeNetwork $PlayerToSwitchToSN");
  $debug && print "$response\n";
  }
  
  close $socket;
  
  # Send given cmd to $socket and return answer with original command removed 
from
  # front if present.  Routine nicked from code by Felix Mueller. :-)
  sub sendAndReceive {
  my $cmd = shift;
  
  return if( $cmd eq "");
  
  print $socket "$cmd\n";
  $debug > 1 && print "Sent $cmd to server\n";
  my $answer = <$socket>;
  $debug > 1 && print "Server replied: $answer\n";
  $answer =~ s/$cmd //i;
  $answer =~ s/\n//;
  
  return $answer;
  }
  
  
--------------------

In a windows environment, I would suggest looking at my SCCLITool:
http://forums.slimdevices.com/showthread.php?t=52951

Using that utility in a cmd file fired off periodically by the windows
task scheduler, one ought to be able to accomplish pretty much the same
thing.

In terms of server _wakeup_, if you are really hankering for wakeup
music from your own server, I would suggest playing around with the rtc
alarm wakeup facility that should be built into your server's BIOS. 
Most motherboards less than 5 years old have them, I believe.


-- 
gharris999
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=48521

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/plugins

Reply via email to