How do I schedule the on/off time of the wifi radio?
By starting with a google search https://www.google.com/search?q=openwrt+wifi+onoff and looking at the first link it returns
EDIT: There seems to be a luci-app package for this, didn't try it.
If you are looking after a scheduled on/off at specific hours, you could use a CRON job. More details on "Wifi Schedule on OpenWrt Help".
More detailed version there (be sure to replace reboot
by wifi up
for your case):
https://cucumberwifi.io/community/tutorials/openwrt-schedueling-tasks.html
And finally, one last link on CRON general information from OpenWrt:
https://wiki.openwrt.org/doc/howto/cron
Thanks...just one question: in my case (attached pic) the names of wireless interfaces are radio0 and radio1?
Did you try to install the Wifi Scheduler that has a gui? It should be the easiest way to go and take care of that automatically.
On the software package manager in the gui you can install these:
https://openwrt.org/packages/table/start?dataflt[Name_pkg-dependencies*~]=Wifischedule
Ok...I'll try with this package and not with cron job
just cronjob:
echo "0 23 * * * uci set wireless.@wifi-device[0].disabled=1; wifi" >> /etc/crontabs/root
echo "0 7 * * * uci set wireless.@wifi-device[0].disabled=0; wifi" >> /etc/crontabs/root
echo "root" > /etc/crontabs/cron.update
/etc/init.d/cron enable
/etc/init.d/cron start
/etc/init.d/cron restart
wireless.@wifi-device[0]
probably is radio0, wireless.@wifi-device[1]
probably is radio1 (this is by convention)
I'm using the following small snippet on my boxes, maybe others find this useful, too:
#!/bin/sh
#
# ap-toggle script
# written by Dirk Brenken (dev@brenken.org)
# usage:
# ap-toggle.sh on <radio> => switch the AP on all radios "on", you can limit this with the optional <radio>-parm
# ap-toggle.sh off <radio> => switch the AP on all radios "off", you can limit this with the optional <radio>-parm
# reference this script in /etc/crontabs/root and restart cron service afterwards, e.g.:
# 0 00 * * * /usr/bin/ap-toggle.sh off
# 0 06 * * * /usr/bin/ap-toggle.sh on
#
# This is free software, licensed under the GNU General Public License v3.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# set initial defaults
#
LC_ALL=C
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
apt_ver="0.5"
apt_sysver="$(ubus -S call system board | jsonfilter -e '@.release.description')"
apt_action="${1}"
apt_radio="${2}"
. "/lib/functions.sh"
# f_prepare: gather wireless information & enable/disable AP interfaces
#
f_prepare()
{
local config="${1}"
local mode="$(uci -q get wireless."${config}".mode)"
local radio="$(uci -q get wireless."${config}".device)"
local disabled="$(uci -q get wireless."${config}".disabled)"
if [ "${mode}" = "ap" ] && ([ -z "${apt_radio}" ] || [ "${apt_radio}" = "${radio}" ])
then
if [ "${apt_action}" = "on" ] && ([ -z "${disabled}" ] || [ "${disabled}" = "1" ])
then
uci -q set wireless."${config}".disabled=0
elif [ "${apt_action}" = "off" ] && ([ -z "${disabled}" ] || [ "${disabled}" = "0" ])
then
uci -q set wireless."${config}".disabled=1
fi
fi
}
config_load wireless
config_foreach f_prepare wifi-iface
# commit & reload all changes, write final log message
#
if [ -n "$(uci -q changes wireless)" ]
then
uci -q commit wireless
ubus call network reload
apt_radio="${apt_radio:="all radios"}"
logger -t "ap-toggle-[${apt_ver}] info " "AP on ${apt_radio} has been switched '${apt_action}' (${apt_sysver})"
fi
Some feedback for Netgear R7800 on 17.01.4: Installed wifischedule with luci support, working fine. I am only using 5ghz with one VAP and power consumption went down from 6,9W to 5,7W when wifi is off.
The experimental option with unloading modules didn't work (automatically detected: ath10k_pci,
ath10k_core, compat), wifi didn't came up.
The WRT1900ACS factory firmware only allows the scheduling of both radios; however, I wish to have the two radios turned off/on on different schedules. As far as I have read about CRON or the OpenWRT gui, they also have a single control for both radios. Would someone please confirm this to save me from having to install OpenWRT - since that is the only feature I seek in a non-factory firmware? Thank you!
I've got a WRT1900ACS also and am able to turn the radios off independently via 'wifi down radio0' etc.
Thank you, pbel! Am I correct to assume that you're running 18.06.1 and that the schedules need to be set with the command line interface and not a gui?
Correct, I am using 18.06.1. You can use the GUI to schedule the on/off (just go to System->Scheduled Tasks in luci... that lets you edit the crontab entries in your web browser)
You've given me enough information for me to delve into OpenWRT. I'm looking forward to not having to turn off/on 5 gHz twice daily! Much appreciated, phil!
Is there a reason not to use
crontab -e
with eg
0 23 * * * /sbin/wifi down
0 10 * * * /sbin/wifi restart
5 10 * * * /sbin/reboot
Does a reboot start wifi in any case? In this case the 2nd line would be useless.
I think it is not possible to start the router with a cronjob, if so I would prefer halt instead of "wifi down"
Yes, if you are still connected and don't want a forced wifi shutdown at a fixed time.
I have set up 2 different SSIDs. One is for me, the other one for my kids.
I want do enable and disable only the kids SSID by time schedule. with wifi-schedule you cannot disable a specific SSID. Only all WIFI-connections or none. Does anybody know another plugin?
normal cron
Pretty closely explained in message 7 of this thread.
(the message contains commands to create rows to the crontab file, which you could naturally also edit by hand)
That enables the whole radio, not a single SSID, so you would need to modify the command a bit. Not the whole radio, but just the SSID you want to disable.
wireless.default_radio1.disabled='1'
You can use " uci show wireless
" to see properly your current config.
So if I wanted to disable a specific ssid I would use something like this? :
0 23 * * * uci set wireless.wifinet2.disabled=1; wifi
0 7 * * * uci set wireless.wifinet2.disabled=0; wifi
this is the output of my uci show wireless:
wireless.radio0=wifi-device
wireless.default_radio0.ssid='Admin2.5g'
wireless.default_radio1.ssid='Admin5g'
wireless.wifinet2=wifi-iface
wireless.wifinet2.device='radio1'
wireless.wifinet2.ssid='Kids5g'
wireless.wifinet2.network='KidsLan'
wireless.wifinet3.device='radio0'
wireless.wifinet3.ssid='Kids2.5g'
wireless.wifinet3.network='KidsLan'
Looks right to me. Kids would lose 5 GHz wifi for the night.