Wifitoggle configuration with luci?


#1

Is it possible to configure wifitoggle wigth luci?

root@archerc7v5:~# opkg list-installed | grep toggle
wifitoggle - 1-5

I cannot find it in the webconfiguration menu.

https://oldwiki.archive.openwrt.org/doc/uci/wifitoggle

Is the only way vim /etc/config/wifitoggle ?

config wifitoggle
        option button   'wps'

        option persistent       '0'
        option timer            '600'

        #option led_sysfs               'wrt160nl:amber:wps'
        # Leaving this option empty, makes sure that no LED is touched
        option led_sysfs                ''
        option led_enable_trigger       'timer'
        option led_enable_delayon       '500'
        option led_enable_delayoff      '500'
        option led_disable_default      '0'

I didn't find out how to disable wifi eg from 1m to 2pm.


#2

https://openwrt.org/docs/guide-user/network/wifi/wifitoggle

refers to

https://openwrt.org/docs/guide-user/network/wifi/wifi_toggle

as a more sophisticated(?) or robust(?) package.

I don't see mention of LuCI in that write up.

openwrt/feeds/luci$ egrep -ri 'wifi.*toggle' .

doesn't return anything either.


#3

According to the Documentation there is no LuCI package for this but you can always create a schedule task for disabling the Wi-Fi and then turning it back on another time.

Something like:

25 6 * * * uci set wireless.radio0.disabled=1; uci commit wireless; wifi # at 6:25 am everyday disable it
30 18 * * * uci set wireless.radio0.disabled=0; uci commit wireless; wifi # at 6:30 pm everyday enable it

For more info see: Cron Docs.

Edit: There is also mention of ifconfig in the old forum. If you have more than one SSIDs available and only want to disable one of them then ifconfig wlan0 down would be helpful along with ifconfig wlan0 up command followed bt wifi command so all the changes take effect. Be sure to change it for your circumstances according to the Wi-Fi interface you want to disable.


#4

I tried crontab -e with vi, but then the cronjob didn't work. crond was restarted. So do I need uci for a cronjob?


#5

Edit: Now I see, you meant to put these lines in a crontab and I thought to execute it in a shell. I am not familiar with uci, I never used it. I always edit config-files directly.

root@archerc7v5:~# 0 1 * * * uci set wireless.radio0.disabled=1; uci commit wireless; wifi
-ash: 0: not found

Lets see, if this works (in the meantime I am sure your code works, my fault). The advantage of the script is, that it can be executed easily without the cronjob:

root@archerc7v5:~# cd /root
root@archerc7v5:~# vim wifi_off.sh # content see below

root@archerc7v5:~# chmod +x wifi_off.sh 

root@archerc7v5:~# vim wifi_on.sh # content see below

root@archerc7v5:~# chmod +x wifi_on.sh 

root@archerc7v5:~# cat wifi_off.sh 
#!/bin/sh

uci set wireless.radio0.disabled=1
uci set wireless.radio1.disabled=1
uci commit wireless
wifi


root@archerc7v5:~# cat wifi_on.sh 
#!/bin/sh

uci set wireless.radio0.disabled=0 # disable this line, if 5GHz is not needed
uci set wireless.radio1.disabled=0
uci commit wireless
wifi


root@archerc7v5:~# crontab -e  # content see below

root@archerc7v5:/etc/crontabs# cat root 

0 1 * * *  /root/wifi_off.sh
0 11 * * *   /root/wifi_on.sh

root@archerc7v5:/etc/crontabs# /etc/init.d/cron restart

Does the power button corrupt the filesystem
#7

Yes you are right, it can be easily executed but you still need cron to execute it. You would just replace the commands with the path to execute the script.
I am not sure if your cron tasks will still work because you put the commands wrongly there, it should be:
0 1 * * * /root/./wifi_off.sh because this is how you execute a script, with a leading ./. You may also need to give the script, execution permission with chmod +x /root/script_name or else it may not work.