Community discussions

MikroTik App
 
gotsprings
Forum Guru
Forum Guru
Topic Author
Posts: 2118
Joined: Mon May 14, 2012 9:30 pm

Scheduling SSIDs by Day and Date

Mon Jul 09, 2018 10:14 pm

What is everyone doing to turn SSIDs on and off during business hours?

Some sort of scheduler for day vs date would be one of the last things on my list of, "Well I had it from other manufactures."

I have a netwatch that cuts off the guest WiFi when the main ISP goes down. That is done using netwatch and...
/caps-man actual-interface-configuration disable [find configuration.ssid="Guest WiFi"]
That turns off the virtual AP. So none of this... "I can connect but can't get anywhere."

I was writing a time range test... but it would be different per day...

Was wondering if I was over thinking it.

I.E.
Primary ISP is up. Allow Guest
Time Range is correct. Allow Guest

So basically assign the true condition a 1 and false a 0.
Basic script that uses :put could check. If its not 2... turn off SSID.
 
gotsprings
Forum Guru
Forum Guru
Topic Author
Posts: 2118
Joined: Mon May 14, 2012 9:30 pm

Re: Scheduling SSIDs by Day and Date

Fri Jul 13, 2018 2:41 pm

Still trying to figure out the "day thing"...

But... the code for enable disable based on a time range...
:local timetest [/system clock get time]

:if (($timetest>09:00:00)and($timetest<17:00:00)) do={/caps-man actual-interface-configuration enable [find configuration.ssid~"Guest"]} else= {/caps-man actual-interface-configuration disable [find configuration.ssid~"Guest"]}

 
User avatar
antonsb
MikroTik Support
MikroTik Support
Posts: 387
Joined: Sun Jul 24, 2016 3:12 pm
Location: Riga, Latvia

Re: Scheduling SSIDs by Day and Date

Fri Jul 13, 2018 3:16 pm

Interface is not disabled because it's probably dynamic, try setting them as static under provisioning:
/caps-man provisioning set [find] action=create-enabled
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Scheduling SSIDs by Day and Date

Fri Jul 13, 2018 3:41 pm

You can try something like this; enable/disable interface based on configuration name on a per-weekday-scheduler entry.
Since actual-interface-configuration cannot be enabled/disabled and interface don't display higher defined configuration values,
configuration (name) is the better choice.
/system scheduler
# Monday
add interval=1w name=mon-09:00:00 on-event="/caps-man interface enable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/09/2018 start-time=09:00:00
add interval=1w name=mon-17:00:00 on-event="/caps-man interface disable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/09/2018 start-time=17:00:00
# Tuesday
add interval=1w name=tue-09:00:00 on-event="/caps-man interface enable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/10/2018 start-time=09:00:00
add interval=1w name=tue-17:00:00 on-event="/caps-man interface disable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/10/2018 start-time=17:00:00
# etc..etc..
 
gotsprings
Forum Guru
Forum Guru
Topic Author
Posts: 2118
Joined: Mon May 14, 2012 9:30 pm

Re: Scheduling SSIDs by Day and Date

Fri Jul 13, 2018 4:45 pm

Interface is not disabled because it's probably dynamic, try setting them as static under provisioning:
/caps-man provisioning set [find] action=create-enabled
No.

My example works.

What is not done is the ability to adjust that time range per day.

I made a :global variable with the time range test. Which I can get my script to pick up. It imports the variable... but doesn't execute it.

viewtopic.php?f=9&t=136669
 
gotsprings
Forum Guru
Forum Guru
Topic Author
Posts: 2118
Joined: Mon May 14, 2012 9:30 pm

Re: Scheduling SSIDs by Day and Date

Fri Jul 13, 2018 4:53 pm

You can try something like this; enable/disable interface based on configuration name on a per-weekday-scheduler entry.
Since actual-interface-configuration cannot be enabled/disabled and interface don't display higher defined configuration values,
configuration (name) is the better choice.
/system scheduler
# Monday
add interval=1w name=mon-09:00:00 on-event="/caps-man interface enable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/09/2018 start-time=09:00:00
add interval=1w name=mon-17:00:00 on-event="/caps-man interface disable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/09/2018 start-time=17:00:00
# Tuesday
add interval=1w name=tue-09:00:00 on-event="/caps-man interface enable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/10/2018 start-time=09:00:00
add interval=1w name=tue-17:00:00 on-event="/caps-man interface disable [find configuration=\"cfg-Guest\"]" \
    policy=read,write start-date=jul/10/2018 start-time=17:00:00
# etc..etc..
If unit reboots this schedule will not work.

I have a script that runs at start up that sets the day of the week.
There is also a script that sets the day of the week at 00:00:01 each day.
I was going to use this same variable to set the $GuestSchedule per day.
So you have one script that is constantly running. It should pick up the Timerange perday based on having that written as a global variable.

But once it imports the variable from :global GuestSchedule... it does not execute the commands in the variable... i.e.
:global GuestSchedule ($timetest>09:00:00)and($timetest<17:00:00)
Then the script that runs every 5 minutes... regardless of day...
:local timetest [/system clock get time]
:global GuestSchedule

:if ($GuestSchedule) do={/caps-man actual-interface-configuration enable [find configuration.ssid~"Guest"]} else= {/caps-man actual-interface-configuration disable [find configuration.ssid~"Guest"]}
I get a complaint of "value is not boolean".
Meaning it picks up the data but doesn't "execute it".

There is other logic in the script to check other conditions like "Primary Gateway Up Or Down." And to check if there is an actual change 1 or 0. This is to cut down on constantly enabling or disabling an interface once the condition is met.

Who is online

Users browsing this forum: No registered users and 50 guests