Timer for selected SSIDs

Hello, I have a number of SSIDs in my house. I would like to disable some at specific times (e.g. the one that the kids use for example).
I am aware that there is a package to do so for the whole radio, but I need to keep the Wi-Fi up for home automation for example. Any idea? Thanks!

Thanks for your reply.
While it does work, it is a hardly maintainable approach...
I am sure this could be a welcome extension to the scheduler package!

put it in the crontab ...

Here is a script, that will create the necessary cron jobs for you.

cat << "EOF" > /root/startstop.scr
#!/bin/sh
ssid=$1
start=$2
stop=$3
prefix=$(uci show wireless | grep "$ssid" | sed s/.ssid.*//)
starth=$(echo "$start" | awk '{split($0,t,":"); print t[1]}')
startm=$(echo "$start" | awk '{split($0,t,":"); print t[2]}')
stoph=$(echo "$stop" | awk '{split($0,t,":"); print t[1]}')
stopm=$(echo "$stop" | awk '{split($0,t,":"); print t[2]}')

echo "$startm $starth * * * uci set $prefix.disabled='0' && wifi # SSID $ssid starts at $start" >> /etc/crontabs/root
echo "$stopm $stoph * * * uci set $prefix.disabled='1' && wifi # SSID $ssid stops at $stop" >> /etc/crontabs/root

/etc/init.d/cron restart
exit 0
EOF
chmod 755 /root/startstop.scr

Use it that way:

/root/startstop.scr ssidname starttime stoptime

Example:

root@OpenWrt:~# /root/startstop.scr myssid 08:00 22:00
root@OpenWrt:~# crontab -l
00 08 * * * uci set wireless.wifinet3.disabled='0' && wifi # SSID myssid starts at 08:00
00 22 * * * uci set wireless.wifinet3.disabled='1' && wifi # SSID myssid stops at 22:00

You'll need to manually edit the crontab if you want to remove the jobs.

2 Likes

thank you, appreciated!

1 Like