Changes

From Amahi Wiki
Jump to: navigation, search
3,831 bytes added ,  03:42, 23 June 2020
{{MessageBox|backgroundcolor = #FBB|
image =Warning.png|
heading =WARNING|
message = This is no longer supported on Amahi 6 or greater.}}
 
[[Image:Amahi-Energy-Saver_Logo.png|150px]]<br>
==General==
This project is approaching in solid betastage. It runs fine on my machine, however I need more feedback from the community to be sure that it's stable enough for the general publicInstallation requires a little Linux knowledge. So, please test and report your experience!
If you like it, like it on facebook: <br>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 project aims at sending application tells your Amahi server to suspend or poweroff power off when its services are not needed.
To do so, 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 fucntion 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===
==Download==The easiest way is to install [http://www.amahi.org/apps/amahi-energy-saver 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
Latest untested sources are available at Git:https://github.com/jayrockk/Amahi-Energy-Saver ==* Initial setup==installation
1. Copy the tar.gz file from the download page to some folder and unpack it with
{{Code|Code= tar -zxf filename}}
2. Open a terminal, change to that folder and get superuser rights by running <code>su</code>
3. As root, run
{{Code|Code=
./aes-install.sh
}}
4. Navigate to {{Code|Code= cd /usr/share/aes}} and run {{Code|Code=installfiles ./aes.rb --shownetworkhosts}}to show and select to add any currently active network host to the list of monitored hosts. Run {{Code|Code=./aes.rb --showmonitoredhosts}}to check the monitored hosts and delete the ones you want to removeinstall.sh
54. As root, run {{Code|Code=service aes start}}to start the service. Be careful, when you start When the service the sytem MAY go to sleep when you don't expect it. Once it works as you want itinstallation is finished, run{{Code|Code=chkconfig aes on}}to make reboot the service start on bootcomputer.The config app is accessible at
<nowiki>http://hda:6500</nowiki>
==Integration with Amahi calendar==
1. Open a terminal on your hda.
===Step-by-step guide===1. In the config app, select ical in the Calendar field. 2. Type Hit the "Apply button in the config app{{Code|Code3. 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"su}}[[Image:AES_Sunbird_1.jpg]]<br>   Press "Next". Choose "iCalendar (ICS)" in the dialog and provide your root passwordtype "http://calendar/aes.ics" in the Location field. [[Image:AES_Sunbird_2.jpg]]<br>   Press "Next". In the following dialog you may deselect the checkbox "Show Alarms", though it's not neccessary for Amahi Energy Saver to work. [[Image:AES_Sunbird_3.jpg]]<br>   Press "Next" then "Finish". You will notice an exclamation mark next to the calendar on the right tab.  [[Image:AES_Sunbird_4.jpg]]<br>  
3Right click the calendar, select "Properties" and make sure "Read Only" is deselected. Type {{Code|Code=cd /usr/share/aes}}
4[[Image:AES_Sunbird_5. Type {{Code|Code=./aes --calendar ical}}jpg]]<br>
4b. To be sure, restart the service by typing
{{Code|Code=
service aes restart
}}
5. Only required for 0.3.6 and below: Open your HDA dashboard and go to "Settings" -> "Calendars".
6. Only required for 0Finished.Below is an example screenshot with a task defined on 2011-07-06 2:30-3:00 and another one 4:30-5:30.6 In the example, the HDA will not go to sleep during these periods, and below: Add a new calendar named <code>aes</code>will wake up if it is suspended.
7. Connect your client to the new calendar. NOTE: Please read this article if you are unsure how to do this: [[CalendarsImage:AES_Sunbird_6.jpg]]<br>
8. Use your favourite calendar client to populate the calendar with events.
==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.
Done! Your HDA will now wake up Please note that MythTV installation itself is non-trivial. The above assumes that MythTV is correctly installed and stay powered on according to the events defined in the aes calendarworking.
==Command Line InterfaceLet other apps control Amahi Energy Saver (version 0.8.12 and later)==*Note: Currently root privileges are required to execute the CLI command. Navigate to /usr/share/aes to use the CLI correctly.
{{Code|Code=./aes.rb --shownetworkhosts}}Lists the hosts found in the network, ie, all devices connected Sometimes you may wish to prevent Amahi Energy Saver from suspending the networkHDA while some other action is ongoing. Gives the user the choice to add hosts There are two simple interfaces to the monitored host listachieve that.
{{Code|Code=./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.==Script interface===
{{Code|Code=.Amahi Energy Saver regularly checks the directory /usr/share/aes.rb --addhost macadress}}Manually add a host to the monitored host listlock for scripts and executes them. Observe If any of the MAC address formatscripts returns an errorlevel of 1, which has to the HDA will not be XX:XX:XX:XX:XX:XXsuspended. Example is <br> <code>Both Bash (*./aessh) and Ruby (*.rb --addhost 12:34:56:78:90:ab</code>) are supported.
{{Code|Code=The scripts can be extremely simple./aes.rb --calendar [off, internal, ical, debug]}}<code>./aes.rb --calendar</code> shows the current setting. <code>./aes.rb --calendar off</code> turns the calendar off, <code>./aes.rb --calendar internal</code> makes aes use its internal calendar function and <code>./aes.rb --calendar ical</code> activates the Amahi calendar integration. To show diag information use <code>./aes.rb --calendar debug</code>In pseudocode a script looks like this:
{{Code|Code=<pre>./aes.rb --showcalendarif (condition) exit 1else exit 0}}endLists 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.</pre>
{{Code|Code=./aes.rb --addcalendar startdate starttime stopdate stoptime}}Use For a collection of scripts, please see this command to add an entry to the internal calendar. Format of startdatethread: http:/stopdate: YYYY-MM-DD Format of starttime/stoptime: hhm:mm. Egforums. <br><code>amahi.org/aesviewtopic.rb --addcalendar 2010-12-20 php?f=15:00 2010-12-20 16:00</code> <br>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.&t=3320&p=16486#p16486
{{Code|Code=./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.==Lock files===
{{Code|Code=.Amahi Energy Saver regularly checks the directory /usr/share/aes.rb --sbs [on, off, debug]}}<code>lock for files with suffix './aeslock'.rb --sbs</code> shows As long as any such file exists, Amahi Energy Saver will not suspend the current settingHDA. <code>This is useful for other applications that support events./aes.rb --sbs on</code> and <code>./aes.rb --sbs off</code> switch monitoring One Event may trigger the creation of Squeezeboxserver on or offthe lock file, respectivelyand another one may delete the lock file. The command <code>./aes.rb --sbs debug</code> displays diagnostic information
{{Code|Code=E./aesg.rb --interval}}aes checks regularly if , the system event that shall cause the HDA to stay awake no matter what can be suspended or shut down. This parameter specifies the time in seconds between two such checks. Normally should be left untouched.call
{{Code|Code=. touch /usr/share/aes --showenergybalance}}View the energy savings in kWh due to the use of Amahi Energy Saverlock/some.lock
{{Code|Code=./aes --setpowerconsumption pc_on pc_standby}}Set When 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.job is finished, the respective event should call
{{Code|Code=. rm -f /usr/share/aes-lock/some.rb --help}}Displays command line helplock
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:<br><br>
 
Deactivated
Amahi Energy Saver is running in the background, however it will never shutdown or suspend the HDA.
Poweroff
* If you are brave or the ACPI options don't work, try mem, disk or standby.<br><br>
==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): [[File:LogAnalyzer_Config_for_Amahi_Energy_Safer.png]]   ==Windows clientfor Wake on LAN==
On the download page there is a Windows client for automatic or manual wakeup of the HDA.
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 right 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.<br><br>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 <br> <code>./aes.rb --addhost 12:34:56:78:90:ab</code>  ./aes.rb --calendar [off, internal, ical, debug] <code>./aes.rb --calendar</code> shows the current setting. <code>./aes.rb --calendar off</code> turns the calendar off, <code>./aes.rb --calendar internal</code> makes aes use its internal calendar function and <code>./aes.rb --calendar ical</code> activates the Amahi calendar integration. To show diag information use <code>./aes.rb --calendar debug</code>  ./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. <br><code>./aes.rb --addcalendar 2010-12-20 15:00 2010-12-20 16:00</code> <br>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] <code>./aes.rb --sbs</code> shows the current setting. <code>./aes.rb --sbs on</code> and <code>./aes.rb --sbs off</code> switch monitoring of Squeezeboxserver on or off, respectively. The command <code>./aes.rb --sbs debug</code> 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
==Logs==Logs are located in /usr/share/aes and named aes.log*[[Category:Apps]]
12,424

edits