Amahi Energy Saver
WARNING | |
---|---|
This is no longer supported on Amahi 6 or greater. |
Contents
- 1 General
- 2 Introduction
- 3 Installation
- 4 Integration with Amahi calendar
- 5 MythTV integration (version 0.8.12 and later)
- 6 Let other apps control Amahi Energy Saver (version 0.8.12 and later)
- 7 Selecting ShutdownType
- 8 Logs and LogAnalyzer
- 9 Windows client for Wake on LAN
- 10 Mac OS X clients for Wake on LAN
- 11 Sources
- 12 OBSELETE: Command Line Interface
General
This is in solid beta stage. Installation requires a little Linux knowledge.
If you like it, like it on facebook:
http://www.facebook.com/pages/Amahi-Energy-Saver/218015224890441
Introduction
Running servers when they are not needed can waste a considerable amount of energy. This application tells your Amahi server to suspend or power off when its services are not needed.
Amahi Energy Saver regularly scans for connected clients, which are defined in the "monitored host list". If none of these clients is turned on, the system suspends after a configurable period.
So, for instance, you may want to add your client PC and your PS3 to the monitored host list. The Amahi Box will then stay up and running as long as client PC and/or PS3 are up and running. However, you might not want to add your home router to the list, as the router is always turned on.
With the calendar function one can define scheduled wake ups and periods during which the server shall stay awake no matter what.
Amahi Energy Saver also checks shares. As long as shares are accessed, the server does not suspend. If set up to do so, Squeezeboxserver is monitored to prevent suspend while Squeezeboxes are turned on.
When the system is to be used again, simply wake it up with WOL (ref. http://en.wikipedia.org/wiki/Wake-on-LAN). There are many tools to generate WOL packets, and it is even possible to wake your server over the internet (good link: http://www.wakeonlan.me/).
Installation
One Click installation
The easiest way is to install Amahi Energy Saver via the Amahi One Click installation.
Manual installation - NOT SUPPORTED ANYMORE, BUT MAY STILL WORK
Download the latest tested and released version here: http://code.google.com/p/amahienergysaver/downloads/list
- Initial installation
1. Copy the tar.gz file from the download page to some folder and unpack it with
tar -zxf filename
2. Open a terminal, change to that folder and get superuser rights by running su
3. As root, run
cd installfiles ./aes-install.sh
4. When the installation is finished, reboot the computer. The config app is accessible at
http://hda:6500
Integration with Amahi calendar
Step-by-step guide
1. In the config app, select ical in the Calendar field.
2. Hit the "Apply button in the config app
3. Connect your client to the new calendar. NOTE: Please read this article if you are unsure how to do this: Calendars
4. Use your favourite calendar client to populate the calendar with events.
Done! Your HDA will now wake up and stay powered on according to the events defined in the aes calendar.
Example: Set up Mozilla Sunbird for use with Amahi Energy Saver calendar
The following description was created based on Sunbird 1.0b1 running on Windows 7.
In Sunbird, select "File" -> "Connect to remote calendar..." A dialog shows up. Choose "On the network"
Press "Next". Choose "iCalendar (ICS)" in the dialog and type "http://calendar/aes.ics" in the Location field.
Press "Next". In the following dialog you may deselect the checkbox "Show Alarms", though it's not neccessary for Amahi Energy Saver to work.
Press "Next" then "Finish". You will notice an exclamation mark next to the calendar on the right tab.
Right click the calendar, select "Properties" and make sure "Read Only" is deselected.
Finished. Below is an example screenshot with a task defined on 2011-07-06 2:30-3:00 and another one 4:30-5:30. In the example, the HDA will not go to sleep during these periods, and will wake up if it is suspended.
MythTV integration (version 0.8.12 and later)
Before Amahi Energy Saver suspends the HDA, it checks with MythTV server if any recordings are scheduled and if so sets the wake up timer accordingly. If the recording folder is one of the shares, it is ensured that Amahi Energy saver will not suspend the HDA while a recording is ongoing.
Please note that MythTV installation itself is non-trivial. The above assumes that MythTV is correctly installed and working.
Let other apps control Amahi Energy Saver (version 0.8.12 and later)
Sometimes you may wish to prevent Amahi Energy Saver from suspending the HDA while some other action is ongoing. There are two simple interfaces to achieve that.
Script interface
Amahi Energy Saver regularly checks the directory /usr/share/aes-lock for scripts and executes them. If any of the scripts returns an errorlevel of 1, the HDA will not be suspended. Both Bash (*.sh) and Ruby (*.rb) are supported.
The scripts can be extremely simple. In pseudocode a script looks like this:
if (condition) exit 1 else exit 0 end
For a collection of scripts, please see this thread: http://forums.amahi.org/viewtopic.php?f=15&t=3320&p=16486#p16486
Lock files
Amahi Energy Saver regularly checks the directory /usr/share/aes-lock for files with suffix '.lock'. As long as any such file exists, Amahi Energy Saver will not suspend the HDA. This is useful for other applications that support events. One Event may trigger the creation of the lock file, and another one may delete the lock file.
E.g., the event that shall cause the HDA to stay awake no matter what can call
touch /usr/share/aes-lock/some.lock
When the job is finished, the respective event should call
rm -f /usr/share/aes-lock/some.lock
Make sure to use individual names for the lock files, so that you don't accidentally delete the lock file of another application.
Selecting ShutdownType
The different options for ShutdownType are explained here:
Deactivated
Amahi Energy Saver is running in the background, however it will never shutdown or suspend the HDA.
Poweroff
This is a full shutdown and should work on most systems. Some mainboards do not allow scheduled wakeup when using this method.
ACPI_S1
Legacy ACPI S1 state. Support depends on mainboard and Fedora support
ACPI_S3
Legacy ACPI S3 state. Support depends on mainboard and Fedora support
ACPI_S4
Legacy ACPI S4 state. Support depends on mainboard and Fedora support
mem
Suspend to memory, is intended to replace ACPI S1 but is not widely supported yet
disk
Suspend to disk, is intended to replace ACPI S4 but is not widely supported yet
standby
Suspend to memory, is intended to replace ACPI S3 but is not widely supported yet
When selecting the shutdown type the following procedure is suggested:
- Start with Poweroff to do basic checking and configuration. Since this is the safest version, it should also be your resort in case of problems.
- Once things are working, select either of the ACPI_S1..3 depending on what level of suspend you want
- If you are brave or the ACPI options don't work, try mem, disk or standby.
Logs and LogAnalyzer
Depending on the version installed the logs are located in /usr/share/aes or /var/hda/web-apps/html/aes/lib.
- From version 0.8.12 onwards, the log files have been moved to /var/log.
In any case the files are named named aes.log*
In order to view the Amahi Energy Saver logs in the LogAnalyzer (ref. http://www.amahi.org/apps/loganalyzer) navigate on your LogAnalyzer homepage to "Admin Center" then "Sources" and finally klick "Add new Source". Configure the new source for the Energy Saver logs as shown in the screenshot below (note that the directory may have to be adjusted, see above):
Windows client for Wake on LAN
On the download page there is a Windows client for automatic or manual wakeup of the HDA.
- Installation
Just run the msi file found on the download page. The client will be included in the startup folder.
- Configuration
1. Form the start menu, run AmahiEnergySaver -> AES Client
2. Right click on the icon that will appear in symbol bar, and select "Show config"
3. To get started, make sure that you set "Host MAC" and "Host name" to your HDA configuration. Hit "Select Server" to bring up the "Select HDA" window, and then "Search". If possible the correct server is alreday selected, in that case just hit "Ok" to confirm. Continue with 4.
If the server appears on the list but is not automatically selected, click on it and hit return.
Should your server not show up at all, press "Cancel" to exit the "Select HDA" dialog and configure MAC and host name manually.
Finally, if requried, change the "Port" setting. The default "9" should work in most cases.
4. Hit the "OK" butten, then right click on the symbol again, select "Exit" and and restart the program as described in 1.
5. Done! You should now be able to start your HDA by double clicking on the icon in the symbol bar and select "Wake now"
Mac OS X clients for Wake on LAN
There exist a few solutions (WOL clients) to wake up your HDA from a Mac OS X computer. In order to wake up your HDA while booting your Mac you may use NASwake (ref. http://trick77.com/2010/12/22/wake-nas-at-boot-time-wake-on-lan-wol/). It comes ready to use as an installable package, you just need to enter the MAC-adress of the HDA.
WakeOnLan is a freeware application provided by Readpixel which offers a very comfortable way to wake up your HDA directly from your Mac OS X desktop (ref. http://www.readpixel.com/wakeonlan/index.html).
Sources
Latest untested sources are available at Git: https://github.com/jayrockk/Amahi-Energy-Saver
OBSELETE: Command Line Interface
- Note: Root privileges are required to execute the CLI command. Navigate to /usr/share/aes to use the CLI correctly.
./aes.rb --shownetworkhosts
Lists the hosts found in the network, ie, all devices connected to the network. Gives the user the choice to add hosts to the monitored host list.
./aes.rb --showmonitoredhosts
Show a list of all hosts which are monitored by AES (i.e. the monitored host list), and also allows to delete hosts from the list. If these hosts are up and running (and respond to ping), the server does not suspend.
./aes.rb --addhost macadress
Manually add a host to the monitored host list. Observe the MAC address format, which has to be XX:XX:XX:XX:XX:XX. Example is
./aes.rb --addhost 12:34:56:78:90:ab
./aes.rb --calendar [off, internal, ical, debug]
./aes.rb --calendar
shows the current setting.
./aes.rb --calendar off
turns the calendar off,
./aes.rb --calendar internal
makes aes use its internal calendar function and
./aes.rb --calendar ical
activates the Amahi calendar integration. To show diag information use ./aes.rb --calendar debug
./aes.rb --showcalendar
Lists the current entries of the internal calendar. Calendar entries define times when the server does not suspend. Also, the server will be woken up at the beginning of a calendar entry.
./aes.rb --addcalendar startdate starttime stopdate stoptime
Use this command to add an entry to the internal calendar. Format of startdate/stopdate: YYYY-MM-DD Format of starttime/stoptime: hhm:mm. Eg.
./aes.rb --addcalendar 2010-12-20 15:00 2010-12-20 16:00
will keep the server awake on Dec 20th, 2010 from 15 to 16 hrs (3 to 4 pm). The server will also wake up at 15 hrs if it is suspended.
./aes.rb --shutdowntype
Show and modifiy the type of shutdown. NOTE: Not all shutdown types may be supported on your system, or may work correctly. Therefore, test that your machine is suspending and coming up correctly before deciding for a setting. Poweroff is safest type.
./aes.rb --sbs [on, off, debug]
./aes.rb --sbs
shows the current setting. ./aes.rb --sbs on
and ./aes.rb --sbs off
switch monitoring of Squeezeboxserver on or off, respectively. The command ./aes.rb --sbs debug
displays diagnostic information
./aes.rb --interval
aes checks regularly if the system can be suspended or shut down. This parameter specifies the time in seconds between two such checks. Normally should be left untouched.
./aes.rb --showenergybalance
View the energy savings in kWh due to the use of Amahi Energy Saver.
./aes.rb --setpowerconsumption pc_on pc_standby
Set the average power consumption when working ("pc_on") and powered off ("pc_standby"). Values given in Watts. pc_on must be greater than pc_standby.
./aes.rb --help
Displays command line help