Turning wifi on/off from lan using tasker on spitz

Hi, I'm trying to turn on/off the wifi using tasker with root. My first step was run shell with the commad:

curl -i -d "luci_username=root&luci_password=MY_PASSWORD" http://192.168.8.1/cgi-bin/luci

Now I got the token.

What should be the command to turn wifi on off using the token?

Hi

Tasker should have an SSH plugin available. You can use the following commands to disable Wi-Fi:

uci set wireless.@wifi-device[0].disabled=1
uci set wireless.@wifi-device[1].disabled=1
wifi

To enable it:

uci del wireless.@wifi-device[0].disabled=1
uci del wireless.@wifi-device[1].disabled=1
wifi

If you prefer to execute this via Curl, you may need to use browser's Developer Tools to inspect the network requests manually.

Thanks a lot.

This is what worked for me (INSTEAD OF MY_PASDWORD NEED TO PLACE THE CORRECT PASSWORD AND REMOVE THE SPACE FROM THE HTTP ADDRESSES):

Turning off 5G:

SESSION_ID=$(curl -k -s -d '{"jsonrpc":"2.0","method":"call","params":["00000000000000000000000000000000","session","login",{"username":"root","password":"MY_PASSWORD"}]}' http:// 192.168.8.1:8080/ubus/ | grep -oE '[a-f0-9]{32}')

curl -k -s --data-raw "[

{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"$SESSION_ID\",\"uci\",\"set\",{\"config\":\"wireless\",\"section\":\"mt798112\",\"values\":{\"disabled\":\"1\"}}]},

{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"$SESSION_ID\",\"uci\",\"set\",{\"config\":\"wireless\",\"section\":\"wifi5g\",\"values\":{\"disabled\":\"1\"}}]},

{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"$SESSION_ID\",\"uci\",\"apply\",{\"rollback\":false}]},

{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"$SESSION_ID\",\"file\",\"exec\",{\"command\":\"/sbin/wifi\",\"params\":[\"down\",\"mt798112\"]}]}

]" http:// 192.168.8.1:8080/ubus/

Turning On 5G:

SESSION_ID=$(curl -k -s -d '{"jsonrpc":"2.0","method":"call","params":["00000000000000000000000000000000","session","login",{"username":"root","password":"MY_PASSWORD"}]}' http:// 192.168.8.1:8080/ubus/ | grep -oE '[a-f0-9]{32}')

curl -k -s --data-raw "[
{"jsonrpc":"2.0","method":"call","params":["$SESSION_ID","uci","set",{"config":"wireless","section":"mt798112","values":{"disabled":"0"}}]},
{"jsonrpc":"2.0","method":"call","params":["$SESSION_ID","uci","set",{"config":"wireless","section":"wifi5g","values":{"disabled":"0"}}]},
{"jsonrpc":"2.0","method":"call","params":["$SESSION_ID","uci","apply",{"rollback":false}]},
{"jsonrpc":"2.0","method":"call","params":["$SESSION_ID","file","exec",{"command":"/sbin/wifi","params":["up","mt798112"]}]}
]" http:// 192.168.8.1:8080/ubus/

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.