Community discussions

MikroTik App
 
Binser
newbie
Topic Author
Posts: 48
Joined: Fri Dec 28, 2018 7:50 pm

Script to disable Wlan when no user are logged on

Tue Jun 11, 2019 8:46 pm

Hello,

I am well on my way to make our MikroTiks environmentally friendly. I have reduced their power output, assigned the mode button to switch wlan on or off, and now I would like the router to disable wlan when all users have disconnected from wlan.

But I haven't figured out this last part yet.

Do you have any ideas how my script can tell that noone is logged on wlan?

Thanks. :)
 
sid5632
Long time Member
Long time Member
Posts: 553
Joined: Fri Feb 17, 2017 6:05 pm

Re: Script to disable Wlan when no user are logged on

Wed Jun 12, 2019 1:46 am

Are you going to enable the WLAN as soon as somebody logs on as well then?
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: Script to disable Wlan when no user are logged on

Wed Jun 12, 2019 6:53 am

Put this in scheduler:
:if ( [ :len [/interface wireless registration find] ] <= 0 ) do={ /interface wireless disable wlan1; :log info "No Wireless Users - Wireless Disabled";}
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to disable Wlan when no user are logged on

Wed Jun 12, 2019 6:17 pm

assigned the mode button to switch wlan on or off, and now I would like the router to disable wlan when all users have disconnected from wlan.
Can you post this script?
 
millenium7
Long time Member
Long time Member
Posts: 538
Joined: Wed Mar 16, 2016 6:12 am

Re: Script to disable Wlan when no user are logged on

Tue Jul 02, 2019 3:06 am

Hello,

I am well on my way to make our MikroTiks environmentally friendly. I have reduced their power output, assigned the mode button to switch wlan on or off, and now I would like the router to disable wlan when all users have disconnected from wlan.
Have you done the calculations to determine how many calories are burned by having to walk over and press the button? Extrapolate out over a year and then determine how much extra food a person needs to eat to compensate, then figure out the environmental impact of producing that extra food, then multiply by the number of people that are doing the same thing (Hint: the answer is 1, its just you)

This whole exercise makes very little sense and will have absolutely sweet FA impact on power consumption and environmental impact. WiFi access points periodically send out a small pulse when they aren't in use, the power required is absolutely tiny. All it does is make your life more difficult by having to keep turning it back on
 
sid5632
Long time Member
Long time Member
Posts: 553
Joined: Fri Feb 17, 2017 6:05 pm

Re: Script to disable Wlan when no user are logged on

Wed Jul 03, 2019 1:29 am

All it does is make your life more difficult by having to keep turning it back on
No, no, no. The WLAN will automatically turn on as soon as someone connects to it. It's so obvious.
 
joegoldman
Forum Veteran
Forum Veteran
Posts: 766
Joined: Mon May 27, 2013 2:05 am

Re: Script to disable Wlan when no user are logged on

Wed Jul 03, 2019 1:58 am

Well - if its allowing for business hours, you'd disable wifi once last person logs off after say 5-6pm, so it doesnt force them off at a set time in case they are working back, but then leave it off till predetermined time like 7am. All depends on the setup and intent but makes sense to an extent, and I've done similar here (but not for environmental reasons, more for staff coming back at night and sitting in the carpark to steal free internet, developing country and poor populace)
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to disable Wlan when no user are logged on

Wed Jul 03, 2019 3:12 pm

No, no, no. The WLAN will automatically turn on as soon as someone connects to it. It's so obvious.
The best comment in long time :mrgreen:
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: Script to disable Wlan when no user are logged on

Thu Jul 04, 2019 3:48 am

No, no, no. The WLAN will automatically turn on as soon as someone connects to it. It's so obvious.
OK! :mrgreen:
/system scheduler
add interval=10m name=wlan1-auto-on/off on-event=":if ([/interface wireless get wlan1 disabled]=yes) do={\r\
    \n:log info \"Checking for Wireless Users\"\r\
    \n; /interface wireless set wlan1 disabled=no;\r\
    \n:delay 10s;\r\
    \n:if ( [:len [/interface wireless registration find] ] <=0 ) do={\r\
    \n/interface wireless disable wlan1;\r\
    \n:log info \"No Wireless Users\";}  else={\r\
    \n:log info \"Wireless User Detected - Wireless Enabled\";}} else={\r\
    \n:if ([:len [/interface wireless registration find]] <=0 ) do={\r\
    \n/interface wireless disable wlan1;\r\
    \n:log info \"No Wireless Users - Wireless Disabled\";}}" start-time=startup

Who is online

Users browsing this forum: No registered users and 21 guests