Script to disable Wlan when no user are logged on

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. :slight_smile:

Are you going to enable the WLAN as soon as somebody logs on as well then?

Put this in scheduler:

:if ( [ :len [/interface wireless registration find] ] <= 0 ) do={ /interface wireless disable wlan1; :log info "No Wireless Users - Wireless Disabled";}

Can you post this script?

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

No, no, no. The WLAN will automatically turn on as soon as someone connects to it. It’s so obvious.

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)

The best comment in long time :mrgreen:

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