[WIP] Myth Suspend Alarm
#1
I wanted to post this now as I lost the script once when my hard drive crashed unexpectedly (I know, I know...)

Script:
Myth Suspend Alarm

Download: https://github.com/elParaguayo/xbmc-myth...all/master

What it does: Sets an ACPI alarm based on the next scheduled MythTV recording and suspends the machine. I don't use the MythTV frontend, nor do I use MythWelcome. I needed a script that not only checked what MythTV was doing, but also whether XBMC was active.

Who might want to use it: Anyone running a MythTV backend on the same machine as the XBMC frontend (may just be me...).

Legal bit: I make no guarantees that this script won't harm your system, so if it does, don't come running to me as I accept no liability. It works for me. That's all I can guarantee.

Screenshot:
Image

How it works:
The script performs a series of tests and, if all are passed, sets an ACPI and suspends/hibernates the machine.

The tests are as follows:
  • Get MythTV backend status and check if recording/transcoding/running user jobs etc
  • Check if XBMC has any active players
  • Check if there are any active sessions e.g. ssh

Tested on: Dharma

How to use:
(I'll be honest, there's a bit of effort needed on the user's part! But the idea is once it's working, you can forget all about it.)

Unzip the script folder to your addons folder.

There are 2 bash scripts which need to be configured so the script can use them:

setwakealarm: this sets the ACPI alarm. It needs to be executable and, more importantly, able to run as sudo without a password (so you'll need to edit the sudoers file to do this).

mythshutdownstatus: this script outputs the status code (to stdout) of the "mythshutdown -s" command. Again, make sure this script is executable.

Ok, that's the easy bit.

You now need to figure out what your motherboard needs to do to use the ACPI alarm. This is out of the scope of my plugin, but I found the steps on this page http://www.mythtv.org/wiki/ACPI_Wakeup very helpful.

The key thing for the script is to know whether the ACPI alarm needed is a UTC time, or an incremental time (e.g. +600 for an alarm 10 minutes from now). You may need to experiment on the command line first.

NB: you should also test whether your backend is able to record after waking from suspend (see here for my fix: http://ubuntuforums.org/showpost.php?p=1...stcount=18)

You may also want to consider setting up your system to wake from your remote.

Once you've got ACPI suspend/wake working outside of xbmc you can configure the script.

Restart xbmc. The script should appear in addons menu.

The first time you use it, you must configure the script first - the important settings are the paths to the two scripts above and the mythtv database settings.

Once that's done you can try running the script.


Advanced use:


The script can be run as a cron job e.g. by putting the following line in your crontab file:
Code:
0 * * * * xbmc-send -a "RunScript(script.mythsuspendalarm, cron)"
Image

This is version 0.1 so there are bound to be bugs, so all comments bug reports are welcome. However, I'm not a python developer (this is the first python code I ever wrote) so I don't guarantee I can fix the problems!!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply


Messages In This Thread
[WIP] Myth Suspend Alarm - by el_Paraguayo - 2011-07-20, 22:48
[No subject] - by el_Paraguayo - 2011-07-20, 22:49
[No subject] - by dteirney - 2011-09-10, 03:58
[No subject] - by el_Paraguayo - 2011-09-10, 12:41
[No subject] - by dteirney - 2011-09-11, 06:19
Logout Mark Read Team Forum Stats Members Help
[WIP] Myth Suspend Alarm0