News2005-03-19: New version 0.4 is available for download. Added grub support. Added a lot of processes to check for idle time. Fixed bug with future recordings that are not currently scheduled. You need to enable Freevo's network remote control. See updated config infos above.
IntroOne of the core features of a PVR should be the functionality of an automated system wakeup to perform a scheduled recording and the shutdown afterwards. There is an open-source project called nvram-wakeup  which offers the wakeup part. It was originally designed for the vdr-project. Unfortunately Freevo doesn't offers native support for it.
Bash hackDue to my limited python skills I decided to write a bash script which offers the wakeup and shutdown functionality. Of cource it would be nicer to have a native Freevo support but I needed this feature so much that I gave it a shot. See the wakeup_check-tarball on the download page. Setup shouldn't be difficult at all after you've read this page!
Now that I have the script running for a few days I'm really satisfied with it. It lacks a few features which a native solution would probably offer, but I hope to solve these issues soon. I will discuss this later, maybe I should start with the current features:
The script is designed to run on a standalone Freevo box. It checks for Freevo activity. But what actually means Freevo activity here ? As a bash script it can monitor external program calls from Freevo only. It checks if there is mplayer, mencoder, xine, tvtime, etc. running. If not, it starts counting the idle time. If the idle time exceeds a certain value, it reads the scheduled recordings from /var/cache/freevo/upsoon, checks if there is a recording that will start in less than x sec, continues or aborts otherwise, calls nvram-wakeup and performs a shutdown. The script is executed via cron and when a user shuts down Freevo manually.
As you can see there is one problem right now: The script doesn't detects the following user activities: reading mails or news, checking the weather forecast or watching pictures.
Currently there are two solutions for this problem:
1st: Use an idle time of 1/2h or whatever normally offers you enough time to perfom the non-detectable task with your Freevo box. You can always turn on the radio or music as detached player, go on with the non-detectable task and the bash-script won't bother you.
2nd: A user can start/stop the idle check with a simple lockfile. It could easily be done with the commands-plugin (erase/write a lock file). All you'd have to do to pause/resume the automated shutdown is to choose a Freevo submenu item. You will find detailed infos in one of the following paragraphs.
SetupFirst of all you need a running nvram-wakeup. You should get the current version from CVS, the tarball is quite outdated and doesn't support lots of motherboards. There is a good setup info written from Hubertus Sandmann available at . My script supports wakeup with/without reboot. If your hardware needs a reboot to perform a proper wakeup, you have to add a new entry to your boot manager. Both lilo and grub are supported as boot manager. While lilo is running out-of-the-box grub needs to be patched. If you're using lilo you need a valid section named "PowerOff" in lilo.conf, as described in the setup infos from :
label = PowerOff
root = /dev/hda2
initrd = /boot/initrd
append = "0"
# set "0" to your default entry
savedefault --default=0 --once
Let's start with the script part. Add:
ENABLE_NETWORK_REMOTE = 1
The next step would be to setup the variables in the bash script. There are mostly self-explanatory. We should take care of the boot manager related variables first:
- $NEED_REBOOT: set it to 1 if your hardware needs a reebot to wakeup properly. You will understand this if you have allready setup nvram-wakeup.
- $BOOTLOADER: only necessary if your hardware needs a reboot. Choose your bootloader: "lilo" oder "grub" are supported.
- $ENTRYNR: only necessary if your using grub as bootloader. Entry nr of the poweroff-section in grub.conf/menu.lst. Be aware: counting starts at "0", so "1" would be your second entry.
Second check these vital variables - if they aren't configured properly, the wakeup-script won't work:
- $UPSOON: the freevo file with the scheduled recordings, usually located at /var/cache/freevo/upsoon
- $PATHTONVRAM: the path to the nvram-wakeup binary
- $UTCADJUST: I'm afraid this value could be hard to understand. It corrects the time difference between the bios time and the current system time of your freevo box. If both times are set to UTC or to local time, you should set this variable to 0. If your bios is set to UTC time, you should set it to the amount of seconds your local time differs from UTC. For Germany, which is UTC+1h the value has to be "- 3600". For USA east coast wich is UTC-6h, the value has to be "+ 21600". If you set this variable to a value which doesn't reflects your real time difference between bios and system time your recordings will always start at a false time.
- $SEARCHSTRING[*]/$STRING_AT: if your freevo box is running in English language there is no need to change these variables. Otherwise you have to convert these strings to your language freevo is running with. Do a "cat /var/cache/freevo/upsoon" to see what freevo outputs.
- REMOTE_CONTROL_HOST/REMOTE_CONTROL_PORT: set these two variables to their corresponding values of the same variables in your local_conf.py.
- $CHECKINTERVAL: the interval in seconds of the wakeup_check-cron job
- $MAXIDLE: the max. idle time of the freevo box
If the idle time exceeds the value of $MAXIDLE + 1x$CHECKINTERVALL, the script will shutdown the system.
- $RECORDPADDING: the wakeup time will take this value into account and start earlier if necessary. This variable should match the value of TV_RECORD_PADDING from your local_conf.py. A differing value wouldn't make much sense.
- $SECUNTILSTART: min. seconds between shutdown and next scheduled recording. If the script wants to shutdown it checks this value first. If the seconds until next recording would start are less than this value, no shutdown will be performed.
As I have stated before the bash script lacks some features a native solution would offer. You can build your own tiny freevo integration with the commands plugin. Activate the plugin with:
COMMANDS_DIR = '/path/to/fxd-files'
<command title="Pause automatic shutdown">
<command title="Resume automatic shutdown">
<cmd>rm -f /path/to/wakeup_lock</cmd>
- $CHECKLOCK: full path and filename of the lockfile. If it is present, the automatic shutdown will pause. The file will be removed on every system shutdown.
You can now control the shutdown/wakeup-feature from within freevo. It's not very stylishly, but it works... Last step would be to add a cronjob like:
That's it. Have fun!