Crontab script to turn down Wifi

cronjob to turn down wifi at night gives not disabling 'Wifi_Main_5Ghz' but gives uci: Invalid argument

as script

root@OpenWrt:~# /usr/sbin/cronjon_scripts/AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Night
+ /usr/sbin/cronjon_scripts/AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Night
uci: Invalid argument

Script

AutoTurnDownWifi-40Mhz23db,Enable-Guest,Private@Morning

# AutoTurnDownWifi-40Mhz23db,Enable-Guest,Private@Morning
uci set wireless.radio0.txpower=28
uci set wireless.radio0.htmode=HT40
uci set wireless.radio1.txpower=23
uci set wireless.radio1.htmode=HT80
uci set wireless.Wifi_Geo_Spoof.disabled=0
uci set wireless.WiFiGuest.disabled=0
uci set wireless.Wifi_Main_5Ghz.disabled=0
uci set wireless.WifiPrivate5Ghz.disabled=0
uci commit
/etc/init.d/network reload

AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Night

uci set wireless.WiFi_APGuest.disabled=1
uci set wireless.radio0.txpower=10
uci set wireless.radio0.htmode=HT20
uci set wireless.radio1.txpower=10
uci set wireless.radio1.htmode=HT20
uci set wireless.Wifi_Geo_Spoof.disabled=1
uci set wireless.WiFiGuest.disabled=1
uci set wireless.Wifi_Main_5Ghz.disabled=1
uci set wireless.WifiPrivate5Ghz.disabled=1
uci commit
/etc/init.d/network reload

crobtab

# Wi-Fi Power

## TurnDown - Wi-Fi 20Mhz 10db, Disable SSID Guest/Private @ 12 Midnight (0 0 * * *)
### To avoid infinite reboot loop, wait 70 seconds and touch a file in /etc so clock will update on reboot before cron starts.
55 23 * * * sleep 70 && touch /etc/banner
0 0 * * * /usr/sbin/cronjon_scripts/AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Night

## TurnUp - Wi-Fi 40Mhz 28db and Enable Guest and Private @ 8 AM (0 8 * * *)
### To avoid infinite reboot loop, wait 70 seconds and touch a file in /etc so clock will update on reboot before cron starts.
50 7 * * * sleep 70 && touch /etc/banner
55 7 * * * /usr/sbin/cronjon_scripts/AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Morning

Running as command

## TurnDown - Wi-Fi 20Mhz 10db, Disable SSID Guest/Private @ 12 Midnight (0 0 * * *)
0 0 * * * uci set wireless.radio0.txpower=10 && uci set wireless.radio0.htmode=HT20 && uci set wireless.radio1.txpower=10 && uci set wireless.radio1.htmode=HT20 && uci set wireless.Wifi_Geo_Spoof.disabled=1 && uci set wireless.WiFiGuest.disabled=1 && uci set wireless.Wifi_Main_5Ghz.disabled=1 && uci set wireless.WifiPrivate5Ghz.disabled=1 && uci commit && /etc/init.d/network reload

## TurnUp - Wi-Fi 40Mhz 28db and Enable Guest and Private @ 8 AM (0 8 * * *)

0 8 * * * uci set wireless.radio0.txpower=28 && uci set wireless.radio0.htmode=HT40 && uci set wireless.radio1.txpower=23 && uci set wireless.radio1.htmode=HT80 && uci set wireless.Wifi_Geo_Spoof.disabled=0 && uci set wireless.WiFiGuest.disabled=0 && uci set wireless.Wifi_Main_5Ghz.disabled=0 && uci set wireless.WifiPrivate5Ghz.disabled=0 && uci commit && /etc/init.d/network reload

Terminal

root@OpenWrt:~# set -x && uci set wireless.radio0.txpower=10 && uci set wireless.radio0.htmode=HT20 && uci set wireless.
radio1.txpower=10 && uci set wireless.radio1.htmode=HT20 && uci set wireless.Wifi_Geo_Spoof.disabled=1 && uci set wirele
ss.WiFiGuest.disabled=1 && uci set wireless.Wifi_Main_5Ghz.disabled=1 && uci set wireless.WifiPrivate5Ghz.disabled=1 &&
uci commit && /etc/init.d/network reload
+ uci set 'wireless.radio0.txpower=10'
+ uci set 'wireless.radio0.htmode=HT20'
+ uci set 'wireless.radio1.txpower=10'
+ uci set 'wireless.radio1.htmode=HT20'
+ uci set 'wireless.Wifi_Geo_Spoof.disabled=1'
+ uci set 'wireless.WiFiGuest.disabled=1'
+ uci set 'wireless.Wifi_Main_5Ghz.disabled=1'
uci: Invalid argument
root@OpenWrt:~#

I changed /etc/config/wireless for config wifi-iface to match option ifname

if the problems are different

please create a new post ...

1 Like

You should create a separate shell script for both actions, and then use cron to just launch the specific script at the moment you want

2 Likes

Moved Above

I assume you don't need to lower the power and then disable the wifi ...

if you want to disable all wifi interfaces try this:

1 Like

Have you noticed that one of your commands causes this error:

**uci: Invalid argument**

try running one command at a time to figure out which one your router doesn't like

1 Like

Turn Down script Changes 5Ghz AP from AC to N or Legacy
also because it's is set to legacy width is not changes from 20Mhz to 80

# AutoTurnDownWifi-20Mhz10db,Disable-Guest,Private@Night
uci set wireless.radio0.txpower=10
uci set wireless.radio0.htmode=HT20
uci set wireless.radio1.txpower=10
uci set wireless.radio1.htmode=HT20
uci set wireless.Wifi_Geo_Spoof.disabled=1
uci set wireless.WiFiGuest.disabled=1
uci set wireless.Wifi_Main_5Ghz.disabled=1
uci set wireless.WifiPrivate5Ghz.disabled=1
uci commit
/etc/init.d/network reload

@ncompact @hnyman

How to turn off all 5Ghz with one command instead off disabling each SSID in it ?

@hnyman @ncompact

you should be able to set the radio1 as disabled instead of the SSIDs...
(assuming that your radio1 is the %GHz)

uci set wireless.radio1.disabled=1
1 Like

uci set wireless.radio1.disabled=1 & uci set wireless.radio1.disabled=0

Also changes 5Ghz AP from AC to Legacy

I just disable the 5ghz radio at nighttime and turn them on in the morning as below :

0/10 23 * * * uci set wireless.wifinet2.disabled=1; uci commit; wifi
0/10 23 * * * uci set wireless.wifinet3.disabled=1; uci commit; wifi
0/10 7 * * * uci set wireless.wifinet2.disabled=0; uci commit; wifi
0/10 7 * * * uci set wireless.wifinet3.disabled=0; uci commit; wifi

What is ;

What is ; wifi

For me command in scheduled task didn't work so I used it inside file (see main threat).

2 Likes
uci set wireless.radio1.htmode=HT20
uci set wireless.Wifi_Main_5Ghz.disabled=1
uci set wireless.WifiPrivate5Ghz.disabled=1
uci commit
/etc/init.d/network reload

uci set wireless.radio1.disabled=0

both changes AC to Legacy

The wifi command restarts the whole wifi,

Also your names might not be the same as my device and you might need to use
uci show wireless to show your wireless devices and networks.

This is the output of my device:

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'
1 Like

How to set it back to AC using command line ?

Can you explain what this means?

Are you witnessing some other config changes that you didn't make?

Yes
uci set wireless.radio1.disabled=1 & uci set wireless.radio1.disabled=0

Link to main thread

uci set wireless.radio1.txpower=10
uci set wireless.radio1.htmode=HT20
uci set wireless.Wifi_Main_5Ghz.disabled=1

changes 5Ghz AP from AC to Legacy

you need to specify HW mode or band depending on your openwrt version:

hwmode:
Specifies the hardware mode, possible values are 11b for 2.4 GHz (used for legacy 802.11b only), 11g for 2.4 GHz (used for 802.11b, 802.11g and 802.11n) and 11a for 5 GHz (used for 802.11a, 802.11n and 802.11ac). Note that 11ng, 11na, 11n and 11ac are invalid options, this setting should largely be seen as controlling the frequency band. (DEPRECATED since 21.02.2, replaced with band)|

eg:
option hwmode '11a'

band:
Specifies the band, possible values are 2g for 2.4 GHz, 5g for 5 GHz, 6g for 6 GHz and 60g for 60 GHz. (NEW since 21.02.2, replaces hwmode)

eg:
option band '5g'

2 Likes

Since the threads have been merged, it's hard to determine what posts you're linking. This is the unfortunate result of creating multiple threads for the same topic - it gets quite confusing. I asked if you are willing to show the setting that changed to AC or explain how that occurred.

Or perhaps you could:

cat /etc/config/wireless

to show us the resulting config that exhibits the issue you describe.

1 Like