[HOWTO] Vero 4K / 4K+ / Vero V: Performing actions programatically on Standby and Wakeup

There have been some requests to control behaviour when Vero 4K / 4K + is put in to or woken from standby using via the Power → Suspend option.

It is now possible (as of the 2018-12.1 update) to run scripts when toggling standby state.

You can place Python scripts accordingly:

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

If your script is in the right place, you should see the following in your log (debug logging is not required):

CApplication::ToggleStandby – script /home/osmc/.kodi/userdata/wake.py found

or

CApplication::ToggleStandby – script /home/osmc/.kodi/userdata/standby.py found

These are run via Kodi’s context, so you canimport xbmc and use internal Kodi functions.

2 Likes

thanks sam, very useful to control the rest of the media setup.
is the mentioned update a “official” one? I’m not yet familiar with the update cycle on the vero… is there any link to a post to catch up?

That update should be out later today. Check in MyOSMC or wait for the announcement here. If you are not on automatic updates, download it manually.

thanks grahamh, is there any kind of changelog?

A link to the blog post will be provided on this forum at time of release.

3 Likes

Should now be ready

1 Like

Hi Sam,

have seen this by accident in the logs and just tried out - worked first try!
Now my Hyperion setup survives standby/resume cycles without manually restarting the hyperion service!!!

you == legend.

thanks
Anthrax

3 Likes

I’m trying to get my Vero to stop responding to ping requests during standby. I’ve tried the following:

standby.py

import os
os.system('sudo echo "1" >/proc/sys/net/ipv4/icmp_echo_ignore_all')

wake.py

import os
os.system('sudo echo "0" >/proc/sys/net/ipv4/icmp_echo_ignore_all')

However this does not work, the file is not written to (checked by FTP). I see in the Kodi logs that the scripts are called. Obviously the Python syntax is wrong. Can someone help? Thanks!

Hi,

I think its because standby.py & wake.py are run by kodi they are not being run with super user rights. I think the following should get round that:

standby.py

import os
os.system('/bin/bash -c "echo "1" | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_all"')

wake.py

import os
os.system('/bin/bash -c "echo "0" | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_all"')

Thanks Tom.

This did the trick! Thanks a lot and Happy New Year!

1 Like

Is there a way to run a bash script on standby or wakeup?

Yes, the above examples are exactly that. You call open a bash which then can execute a command or a script.

1 Like

Thank you, I got it to work with

import os
os.system('sudo /bin/bash -c /home/path to my script here.sh')

I had to add the sudo though as it wouldn’t run without it. The script just creates a simple text file, which is owned by the osmc user when it’s finished so it will be OK doing it this way?

Did the script had execution flag set for user and is owned by user osmc?

Yes