Kodi Community Forum

Full Version: [VDR] Automatic shutdown after recording
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm using VDR with the VNSISERVER plugin as my backend (gentoo-configuration).
In VDR, it is configurable to start at a certain time for a recording and shutdown afterwards.
The booting part is also possible with XBMC of course, but there can be a problem when shutting down:
  • what if I am still watching LIVE TV (or listening a CD, ...) ?
  • is there a check to see whether XBMC is idle ?
In the past I used a script for it but it shutted down my PC once the recording was finished.

Thanks for the ideas,

Jan
I have written a simple program for this purpose. It checks for active timers using the svdrpsend.pl script and listening for lirc commands. if a recording just ended and the last remote command is longer than i.e. 1 hour back (or never happened in case of automatic switch on), it will call shutdown.
Hola,

Is it scripting? Are you willing to share it?
As you describe it, it looks very promising!!

Jan
it is a simple C program:
http://pastebin.com/z3GT8q9S

it calls a perl script to get the time of the next timer:
http://pastebin.com/CEzju2LS
you might want to omit the last block of the perl script, it sets the wakeuptime for my machine.
Thanks!

I'll give it a try!
Hello!

Why not using the automatic shutdown procedure of VDR itself? I just forbid VDR to shutdown when XBMC is still running and XBMC has a timeout. Voila!

XThunder
That's not an option if XBMC starts automatically after boot (even unattended)
That was my first setup.

And if so, you'd still need some logic to check whether someone is actually doing something with XBMC (check for XBMC idle)

Jan
I actually posted something about that here: http://forum.xbmc.org/showthread.php?tid=92325

i dont see something reasonable without changing xbmc shutdown (having interface to block shutdown by an addon) Smile
I don't get that? Even when you start XBMC automatically (like I do by a script), you can configure a timeout in XBMC, after that XBMC stops. The only thing left is to check via VDR shutdown hook whether XBMC is running or not.

Greetings,
XThunder
Hello,

One more thing Huh

I forbid XBMC shutdown just by configuring that it quits instead of halt. Shutdown is also done by a script that checks, whether VDR is recording or not:

Code:
#!/bin/bash

##################################################
#
# Shutdown my HTPC
#
# Prevent shutdown if VDR has something to do.
#
##################################################

# get the relative time difference in seconds between next vdr timer and now
wakeuptime=$(svdrpsend -p 2001 -d localhost NEXT rel|grep 250 |cut -f3 -d' '|tr -d '\r')

# Shutdown only in case of no active timer in the next 10 minutes
if [ "$wakeuptime" = "" -o "$wakeuptime" -gt "600" ]; then

   # Stop the HTPC script if still running
   killall "htpc_loop.sh"

   # and perform the normal shutdown
   sudo shutdown -h now

else

   if ps ax | grep -v grep | grep "xbmc\.bin" > /dev/null
   then

      echo "XBMC running."

   else

      echo "XBMC is not running"

   fi

fi

XThunder
i suggested in Trac that XBMC needs to have it's own power management system for XBMC PVR functionality to work flawlessly.

XBMC needs to handle the power options, not the back-end.

XBMC simply needs to log when the scheduled recording will start... You then set xbmc to "wake computer 5 mins before scheduled recording" and "put to sleep 5 mins after recording" but only if XBMC is in idle for that time.

This would solve the problem across all platforms. With no need for the back-end to control the power options.