WiFi on/off by schedule


As the Vero is designed as always on, and I am running a picture slideshow as screensaver,
I’d like to have the WiFi off during nights to let my NAS go to sleep.
So, is it possible to switch off the WiFi let’s say after midnight, but only if the screensaver is running (prevents to cut off a movie night)?

Surely possible but would require you to write a script to check the Kodi status via json and then switch off the WLAN via connman.
You then could run this script at the given time via cron

WiFi can disabled and re-enabled as follows:

connmanctl disable wifi
connmanctl enable wifi

This should give you something to go with. @fzinken’s suggestion of cron isn’t a bad one

And here is a simple script to get what is currently playing:



PLAYING=$(curl -s --data-binary '{ "jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": [], "playerid": 1}, "id": "VideoGetItem"}' -H 'content-type: application/json;' http://osmc:osmc@$SERVER:8080/jsonrpc | python -c "import sys, json; print json.load(sys.stdin)['result']['item']['label']")

echo "$PLAYING"

So you could expand the script to look at $PLAYING and turn Wifi off if it’s empty. Run it from cron every x minutes, and then at say 8AM have another cron job to turn the wifi back on.

I thought about this a little bit and what I’d do is have a cron job fire at midnight, do my check above and stop wifi if nothing playing, otherwise sleep 1 or 5 minutes and try again. That would be better than starting a cron job every minute…

1 Like

Thanks guys, that gives me something to dig into over the next few days - never used cron or scripting.
I’ll get back when I’m going to try it out.