Wake on lan – how to with OSMC running 24/7?

Hi forum,

I am not new to Kodi, but to OSMC and to the vero 4k+. The last 1,5 years I run Kodi on my Sony android TV accessing files on my NAS. I have installed the advanced wake-on-lan script as a Kodi add-on. Starting Kodi on my TV sends a magic package to the NAS and wakes it up.

So far, so good.

I wonder how to manage a similar wake on lan for my NAS with the vero 4k+ running 24/7.

Since Kodi will not be restarted, there is no wake on lan for my NAS. I read this thread: Kodi on-off based on TV status

but it is two years old and there may be a more elegant solution for the problem how to wake a NAS on lan with OSMC running 24/7.

Thank you for and hints and clues.

regards

Chang

I think this would work, if you use suspend on your Vero4k+, then you can edit wake.py with something like this:

nano /home/osmc/.kodi/userdata/wake.py

paste this:

import socket

s=socket.socket(socket.af_inet, socket.sock_dgram)
s.setsockopt(socket.sol_socket, socket.so_broadcast, 1)
s.sendto('\xff'*6+'\x00\x50\x2c\x01\x99\x52'*16, ("255.255.255.255",9))

edit the last line after 6+ you got to add the mac address of your NAS, then CTRL+x y enter to save the file.

Last step make it executable:

chmod +x /home/osmc/.kodi/userdata/wake.py

Thank you joakim_s for your input.

Maybe i got something wrong. Is the suspend mode on the vero 4k+ something like a sleep mode? If so, how to enter the suspend mode and how to wake up the vero 4k+ with a key on the remote?

The other thing is, that my best guess is that if ther vero 4k+ is in suspend mode, sbdnzb would not run anymore while the vero is in suspend mode. Mainly for sabdnzb i like to run the vero 4k+ 24/7.

Ops i forgot, if you got to Setting->System change to expert mode (at the bottom) and go to power saving you got “Wake on access” might wanna try that first.

Sorry for leading you a stray. Forgot that setting

But to answer your questions, suspend mode throttles the cpu and turns off hdmi. Sbdnzb should run just fine in the background, albeit a little bit less cpu for it.

unfortunately, waking up Kodi from suspend mode does not wake up the NAS.

Any other ideas?

With the previus script, or wake on access?

the wake on access would be the nicest sollution since this would be a “out of the box” feature.

I will try your script tomorrow and will report how it works.

Thanks

This probably isn’t the neatest way to do it, but here’s an add-on called Kodi Callbacks which lets you run a specified task in response to a specified Kodi event. You could configure that to run a wake-on-LAN action after a “resume from idle” event, with the idle time set to 1s. That should have the effect of sending a wake-on-LAN every time you press any button on the remote, assuming it has been more than 1s since you last did something.

That settings sends a magic packet before a request from a network share. You would have to try playing something to test to see if that works for you.

Since I am not successful to configure the “advanced wake on lan” addon or the power saving settings (try to wake up servers) in a way that it send a magic package to wake up my NAS, I tried out joakim_s script.

It gives me the following error found in the kodi log:

2019-10-14 18:14:47.761 T:4066324480 NOTICE: CApplication::ToggleStandby – checking for existence of /home/osmc/.kodi/userdata/wake.py
2019-10-14 18:14:47.762 T:4066324480 NOTICE: CApplication::ToggleStandby – script /home/osmc/.kodi/userdata/wake.py found
2019-10-14 18:14:48.029 T:3398431456 WARNING: CPythonInvoker(6): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
2019-10-14 18:14:48.070 T:3398431456 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<–
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type ‘exceptions.AttributeError’>
Error Contents: ‘module’ object has no attribute ‘af_inet’
Traceback (most recent call last):
File “/home/osmc/.kodi/userdata/wake.py”, line 3, in
s=socket.socket(socket.af_inet, socket.sock_dgram)
AttributeError: ‘module’ object has no attribute ‘af_inet’
–>End of Python script error report<–

and

2019-10-14 18:17:46.894 T:4066324480 NOTICE: CApplication::ToggleStandby – checking for existence of /home/osmc/.kodi/userdata/standby.py
2019-10-14 18:18:09.230 T:4066324480 NOTICE: CApplication::ToggleStandby – checking for existence of /home/osmc/.kodi/userdata/wake.py
2019-10-14 18:18:09.230 T:4066324480 NOTICE: CApplication::ToggleStandby – script /home/osmc/.kodi/userdata/wake.py found
2019-10-14 18:18:09.484 T:3873415904 WARNING: CPythonInvoker(7): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
2019-10-14 18:18:09.524 T:3873415904 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<–
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type ‘exceptions.AttributeError’>
Error Contents: ‘module’ object has no attribute ‘af_inet’
Traceback (most recent call last):
File “/home/osmc/.kodi/userdata/wake.py”, line 3, in
s=socket.socket(socket.af_inet, socket.sock_dgram)
AttributeError: ‘module’ object has no attribute ‘af_inet’
–>End of Python script error report<–

Since I am not a Linux guy, I have no clue what it means and how to maintain.

I will have a closer look to “Kodi Callbacks” but I have not found a way how to call the “advanced wake on lan” script.

Thanks for all your affords.

Sorry to revive the old thread. But I’m facing the same challenge and I am stuck exactly where this thread ended. Trying the script in wake.py by @joakim_s, stuck at the same log error ‘module’ object has no attribute ‘af_inet’. Is there perhaps a way around this?

Hi,

I was very ambitious with the “wake on lan” addon and still, I have my vero 4k+ running 24/7. But I gave up with the wake.py script due to the above-mentioned errors.

I added the “wake on lan” addon to the favorites and run it when I switch the TV on. No erratic starts of the NAS and easy handling, I am happy so far.

1 Like