Solved [OpenElec] Daily Wakeup doesn't work
#1
Question 
System: OpenElec Generic x86_64 version 4.2.1 (latest stable), XBMC 13.2

Hi. I'm trying to do an automatic wake-up each night to update the movie library, but it doesn't seem to work.

I set the "Wakeup Daily" ind Settings>PVR>Power Management, and set the time in the format HH:MM:RR (like 14:05:00) .. I've only done it in the testing fase so far, so the time have been set 5 minutes into the future or so.
The FIRST time i tested this, it worked fine, but it hasn't worked since. The system simply won't wake up from S5 state. I get this error in the log:
Code:
14:50:02 T:140344538003328   ERROR: SetWakeupCommand - failed to execute wakeup command '/storage/.config/setwakeup.sh 1413899100': Unknown error 512 (512)

I've set the "Wakeup Command" to /storage/.config/setwakeup.sh which contains:
Code:
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://localhost:80/jsonrpc

The command works fine in SSH, and it was executed the first and only succesful time the system woke up. but the command is executed every time the system is turned on, even if it is turned on by the remote.

SO my questions are:
1. How do I make the OpenElec/XBMC system wake up at a specific time every night?
2. How do I make a script that only runs when the system has been woken up by the timer, and not anything else?
I though of a timebased workaround in setwakeup.sh, that would only trigger the command if the system was woken up at a specific hour, like:
Code:
if [ "date +%H" > 5 ] && [ "date +%H" < 8 ]
curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://localhost:80/jsonrpc
fi
But I'm not fully into linux syntaxes, so I might need a little help there.

Sources:
http://www.computerhope.com/unix/udate.htm
http://www.dreamsyssoft.com/unix-shell-s...torial.php
Reply
#2
why are you trying to wake up _localhost_? I recon that it must be up and running to execute this script Wink
You will need to set a wakeup in your BIOS.
Reply
#3
(2014-10-22, 08:57)wsnipex Wrote: why are you trying to wake up _localhost_? I recon that it must be up and running to execute this script Wink
You will need to set a wakeup in your BIOS.

The way I understand is, that the command is run AFTER the system have been woken up, but maybe I've misunderstood..
Unfortunately, there is no option to set in the BIOS. Under ACPI configurations there is:
Code:
Option: Current state

Suspend Mode: S3
Repost Video on S3 Resume: Yes
ACPI Version Features: ACPI v3.0
ACPI APIC support: Enabled
AMI OEMB table: Enabled
Headless mode: Disabled
Energy Lake Feature: Disabled
APIC ACPI SCI IRQ: Enabled
USB Device Wakeup From S3: Enabled
High Performance Event Timer: Enabled
HPET Memory Address: FED00000h
But it SHOULD be possible, since it worked the first time..

The system is a Zotac ZBOX ID36
http://www.zotac.com/products/mini-pcs/z...tions.html
Reply
#4
+1 for what wsnipex said.

The machine in my bedroom is set in the BIOS to wake up each morning at 6.59AM. The Alarm Clock addon is set to start playing a radio station at 7.00AM.

You could use a similar method to trigger the library update by setting the URL to contain the JSON call, or you could set up a CRON job to call your setwakeup.sh script at a set time, knowing the machine will be running.

EDIT

If your machine does not have settings in the BIOS for Wake on RTC Alarm, try reading here http://www.mythtv.org/wiki/ACPI_Wakeup
Learning Linux the hard way !!
Reply
#5
Hmm. The CRON job was a good idea, but I'm having trouble.

The CRON job
Code:
*/5 * * * * date >>/tmp/cron-date.log
posts the date to the log file every 5th minute, so the CRON daemon is working fine.
but the job
Code:
*/5 * * * * xbmc-send --action="UpdateLibrary(video)" >>/tmp/cron.log
doesn't do anything, it doesn't even post anything to the log file. But running the command outside of CRON via SSH starts the update process immediately, with the message "Sending action: UpdateLibrary(video)"
Reply
#6
Okay, I found a (kinda shitty) workaround, but now it works.

By connecting the system via ethernet cable and not wireless, I was able to get Wake On LAN working. I then used my Synology's cron job to execute a wake command, followed by a Update Library command.
The file /etc/crontab ended like this:
Code:
#minute hour mday month wday who   command
0       8    *    *     *    root  ether-wake -b MACADDRESS
1       8    *    *     *    root  curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "mybash"}' -H 'content-type: application/json;' http://IPADDRESS:WEBSERVERPORT/jsonrpc

Marking thread as SOLVED.

If anyone have any questions about the method, feel free to post a reply here.
Reply
#7
both can be only a single line/at the same time.
just seperate both commands with ";" or "&&"

edit: you might need a sleep as well to give the host some time to come up.
Reply
#8
(2014-10-22, 12:34)wsnipex Wrote: both can be only a single line/at the same time.
just seperate both commands with ";" or "&&"

edit: you might need a sleep as well to give the host some time to come up.

I am not sure what you are refering to..?
Reply

Logout Mark Read Team Forum Stats Members Help
[OpenElec] Daily Wakeup doesn't work0