Day/Night Toggle with Multiple Sites

I’m looking to set up 20 or so separate sites on a single FreePBX server (different locations, but one organization), however I’m running into some issues regarding time conditions.

I’d like each site to be able to manually override their day/night mode individually. Initially it didn’t seem to be a problem, just set up individual time conditions for the sites and enable the override code. However I have two issues with that.

  1. How can I stop extensions at site A from accidentally toggling site B’s time conditions if they accidentally enter in the wrong override code? Is there a way to allow only certain extensions access to this feature (ie. only a receptionist can toggle it?)

Which in a way brings me to my second question

  1. It would be much nicer if I could use the same Feature Code to toggle day/night at every site (ie. user at site A enters *280 and it toggles the Time Condition for site A only, user B enters *280 and it toggles the Time Condition for site B only). Is there any way to make this happen? Likely I’d have to configure custom contexts for each site?


just a wag… but an agi script could probably be called with you enter the override code and determine ‘who’ entered the code and make the appropriate
system change… something like that… just a thought.


To prevent accidental triggering by someone dialing the wrong code, I use the “Optional Password”. Maybe use the street address number for each location or something simple like that. That prevents accidental triggering…


I think you can only specify the password if you set it up as a Call Flow Toggle Control? But then I believe I’m limited to 10 codes (*280-*289) and I need to set up 20+ sites.

Not being particularly well versed in AGI scripts, how would I go about doing this? My theory would be something like this

Create a custom feature code in ext-featurecodes-custom for *280 that executes the script.Something like
exten => *280,1,exec(somescript)

and then have the script do the following:
if dialingextension == 2[2-3][0-9][0-9] then Goto(from-internal,*272,1)
elseif dialingextension == 2[4-5][0-9][0-9] then Goto(from-internal,*274,1)
elseif dialingextension == 2[6-7][0-9][0-9] then Goto(from-internal,*276,1)
etc etc
else hangup

That matches the sites extension ranges, and then goes to the feature code assigned on the time condition page. Obviously I have no idea what the actual syntax to use but I’m just curious if what I’m thinking will work.

I am really, really new to freepbx / agi scripts… keep that in mind. I created a misc destination and overrid it in my

include => app-miscapps-custom
exten => *111,1,Noop(Running miscapp 1: group_override)
exten => *111,n,Macro(user-callerid,)
exten => *111,n,AGI(group_overide.agi)
exten => *111,n,Goto(ext-featurecodes,${FEATURE_CODE},1)
exten => *111,n,Goto(app-miscapps,1,1)
exten => 1,1,Hangup

;–== end of [app-miscapps] ==–;

then /var/lib/asterisk/agi-bin/group_overide.agi
would get the extenion of the user from:
and based on that extension… return the ‘correct’ FEATURE_CODE using:
$agi->set_variable(‘FEATURE_CODE’, $data);
where $data is the feature code associated with the incomming extension.

… something like that. I don’t know of a way to do the time conditions with out seting up a feature code for each one. It would probably be easier if you could do it that way.

I might be able to take a quick stab at this this weekend if you don’t have a better solution by then… or someone that knows what they are doing explains why this would not work. I am 95% sure that this can work this way… just 10% sure that this is the best way. :wink:


I may end up using call flow anyways, as I came across a blog post on how to increase the number of flows:
I’d much rather use call flows than the time codes, since you can password them as you mentioned, as well as the fact that they set the BLF on the phones. I may still see if I can incorporate Jack’s AGI script to have an additional “standardized” feature code.

That might not actually work because the Flow Control won’t automatically kick-out of override mode like the time condition automatically resets when it switches states. Hrm.