Using the Day/Night Control with a Time Condition

Overriding a Time Condition with a feature code is a request that has been asked for since as long as Time Conditions have been available in FreePBX. It comes up regularly on the forums and there have been many custom versions implemented and posted to solve this problem. We have introduced a Day/Night Control module to provide this ability as mentioned in an announcement a few weeks ago.

The module has been put into FreePBX version 2.3 and we hope by now has gotten plenty of testing. Some users were confused on how to use this module in conjunction with a Time Condition so we felt a short write-up in our technical series is in order.

The Day/Night Control module is similar to many other modules in the system. You can create multiple daynight feature codes and each can be used as a destination from within FreePBX as well as provide two destinations of their own. The feature code itself is nothing more than a two way toggle switch. You can change it to either DAY or NIGHT and the state is toggled each time you dial the feature code.

Let’s walk through a standard example of how one might use this in conjunction with an existing Time Condtion. You have an Inbound Route for your main Company DID, that points to a Time Condition set to ring your receptionist at queue 1200 during the normal business hours of 8:00am to 5:00pm Monday-Friday. After hours, it rings the After Hours IVR. You would like to provide an ability to override the Time Condition with a daynight feature code.

How do we do this when there is no reference to the Time Condition in the Day/Night Control module. Lets step through this example and see how:

  1. Create our new daynight feature code and give it index 0 (or what ever you prefer).
  2. Give this a useful name: Receptionist Override
  3. Set the current mode you want this to be in after hitting submit (probably Day).
  4. Provide an optional Password if you want to require password access to this feature code.
  5. Under DAY destination, choose the Receptionist Time Condition
  6. Under NIGHT destination, choose After Hours IVR
  7. Press Save
  8. Go to the Inbound Route that was pointing to the Time Condition and change it to point to your newly created Receptionist Override Day Night mode destination.

That’s it. What you have created looks like this:




Example of Day/Night Control Feature Code used with a Time Condition


Now you can dial *280, optionally entering a password if configured, and change between the Day mode, where the call continues to be controlled by the Time Condition, or the Night mode, where the call is routed around the Time Condition to the normal After Hours IVR.

Accessing the Day/Night Control from Outside

Down in the comments Dirk brought up and excellent question. He needs to be able to enable/disable the feature code from an outside line: "but how can I do this from an outside line?" Normally you would define a Misc Destination to this feature code and then point a DID or IVR option to that destination. However, it turns out this wasn’t really implemented quite right to allow you to do this (mental note – change that in a future release…). However, you can still use the Misc Destination module to accomplish this task. Here’s how:

  1. Go to the Misc Destinations Module
  2. Type in a meaningful description: Receptionist Override
  3. In the Dial Box type: *280
  4. Now use this Misc Destination as a destination for an Inbound Route, IVR selection, or other means.

The downside to this is that a change in the default Misc Destination feature code (from *28) will not reflect in this and you would have to go back and manually make the change here also. We will look at making this more standard, so that each feature code shows up in the Feature Code list in a future release.

There are plenty of other ways you can use the daynight feature code and there is no need to do it in conjunction with a Time Condition. It is simply a module that can be chosen as a destination by other modules and provides a two way toggle switch to continue the call routing to either its Day or Night destinations. As always, we hope that you enjoy these technical series and would very much like to see some suggestions of what you would like to read about (or we may decide no one is reading these and stop writing…).


19 thoughts on “Using the Day/Night Control with a Time Condition

  1. I just stumbled across this and wow!. It took all of 2 minutes to get it working. I immediately called over to one of our company night owls who likes to take orders late on Fridays and they were ecstatic to have this excellent feature. Now, in that I know that they will also walk out most evenings and forget to change it back, I suppose there is a way to automatically turn it off or to just turn it on for a specified period of time. If not, then this feature still rocks. Thanks a million.
  2. Is there any way of knowing what ‘state’ the System is in from looking a Phone ? Please don’t stop writing these technical Series!They are very informative and useful.
  3. There appears to be a patch here that sets the DEVSTATE of daynight to INUSE or NOT_INUSE

    You can then set an exten ==>
    and set a BLF to that via these instructions

    I’m not so great with code so I am not the one to figure out how to map those together and actually make it work; but I am anxiously awaiting someone to figure it out. Maybe in there will be an easier way.

  4. this looks interesting on the surface, but before getting too excited i need to better understand how this works. using the “closing early example”, let’s say the “normal hours” are 8-5PM but at 3PM we toggle into night mode. everything works great – right? – callers will hear the night mode message. What happens at 8AM the next morning? will the system automatically revert back to the normal mode of operation or will it remain in night mode until we toggle it?
  5. This toggle example only allows you to ‘close’ your business early, not keep it ‘open’ late.

    In the above example, if you normal hours are 9A to 6P Mon-Fri, your time condition would do something in the “Matches” section like route you to a receptionist or a “we’re open” IVR system.

    The ‘after hours’ portion of the Time Condition would route you to something to be done after hours.

    Using the above example, ‘toggling’ would only work to force you to ‘after hours mode’ during the normally Open Time. That’s fine, but it doesn’t do you any good if you’re going to stay open later or for a special occasion. Toggling it then would not re-open the system back to the day mode as the Time Condition would override it. (If you run the Day/Night toggle on Saturday, it would send you to the same ‘after hours’ routine that the Time Condition is already performing, and thus is essentially doing nothing )

    Seems like it would be better to have everything integrated into the Time Condition so that you can:

    Dial *280 to toggle directly between Open and Closed Time Conditions

    It would also be useful to to add some features like:
    Dial *283 to force closed until the next regular ‘open’ hour occurs (auto reset)
    Dial *284 to force open until next regular close (auto reset)

    *283 & *284 would allow you to close early on a Friday and then not have to worry about remembering to ‘reopen’ manually on Monday. When Monday rolled around the system would revert to normal operations. Likewise, if you stayed open later on Friday, it would revert to the ‘closed’ position on Saturday.

    *283 and *284 are just rough ideas. Perhaps it would be better to just have some sort of prompt that asked how many hours to say in the override mode.

    Something like:[code]
    Dial-> *283
    Prompt=”Please enter the number of hours to close the Time Condition”
    User enters time
    After time expires, it reverts back to normal operations.[/code]

    Having the Time Condition and the Day/Night Control in two separate areas is generally confusing. Since it seems like the purpose of Day/Night Control is to alter something already set in a Time Conditions, it make more sense to provide toggles directly in the Time Condition module so as to avoid the logic trap that currently exists.

  6. there are plenty of installations that use daynight independent of timeconditions (or don’t use timeconditions at all). And yes it can get confusing to combine features. It is one of the love/hate relationships with FreePBX because of the amount of flexibility that you can get with a lot of the features. (The biggest pain though is multiple timeconditions chained, but that is another story.
  7. I can see how Day/Night would be useful in other circumstances and since it is useful for things other that just ‘day’ and ‘night’ switching, perhaps it would be better named “Conditional Toggle” or something like that.

    As it is though having to combine Day/Night with Time Conditions to get a true toggle is rather cumbersome. (e.g. forcing ‘open’ as well as forcing ‘closed’ irrespective of the current time condition.) I haven’t sat down and totally figured it out yet, but as it is in the tutorial above, you can only use the *280 to go to ‘closed’ mode (After Hours IVR).

    If the current Time Condition is set to the ‘not matches’ position (‘closed’), then dialing *280 doesn’t really do anything since both end up at the “After Hours IVR” in the above example. Essentially the Day/Night node in the logic flow chart is in the wrong position, it should come after the Time Condition Node. I’m going to try to come up with a alternative form of this tutorial the swaps the two (if possible) I’ll post the results here later if it works.

  8. filmo,
    the tutorial was for a common task that many people want to do. You can configure one or multiple day/night feature codes with other flows to obtain anything you want. Thats the advantage of the flexibility (and the complexity). Having a specific code directly associated with a timecondition (once the timecondition evolves to handle multiple conditions in a single entity) would be useful and may come.
  9. Sorry I’m a newbie about freepbx. We are using 1 time condition *280 to forward a call to a destination (mobile phone).
    Now we need to choose the “mobile phone” so we need to activate *281 and so on…
    I created *281 and *282 and two new destination but when I activate night mode by dialing *281 I can see the activation state but nothing happens….only *280 is currenting working.
    Can someone explain me how can I do? Thank you.
  10. Hi all,

    I would like to know how to set this up in a right way. I’ve upgraded our system from v2.2.1 to 2.5.1 and turned on the Day/Night control.
    The ‘Day’ status forwards to Time Conditions, which are set from 9am-9pm to give it enough margin. When the last person is leaving, he or she dials *280 and it should enable the night-mode, but it didn’t! The night-mode is set to Ring Groups ‘closed’. I’ve called our officenumber within the 9am-9pm time conditions, but I just got our receptionist… Do I need to change something in the inbound route? Under what circumstances do I need to set ‘Day/Night Mode’ to ‘(0) Day/Night Switch’?

    Is their anyone who can provide me with a simple step-by-step tut on how to set this up (I thought it would be really rimple and obvious)?
    – office opens at 9am and normally closes at 6pm
    – time conditions are set to 9-9pm to create some margin
    – the last person leaving needs to dial *280 to switch from day to night mode
    – next morning the system needs to automatically switch back to day mode at 9am

    Thanks in advance!


  11. you define that using the time conditions module. Please post questions in the user forum section and not under the documentation section as you will become frustrated when nobody responds to you as we don’t go looking for questions to answer here.
  12. I had the “feature not available” and it took me a long time to find the answer and so for completeness to this post I wanted to provide my result. I had been using the Linksys SPA941 and it had only been sending “28” which if I had looked closely at my log I would have recognized the issue sooner. The phone should have been sending the expected “280” digits. Modifying the dial plan on the phone fixed the problem. I know I may get flamed for this post as answers to questions are found in the forum, but I could not find this answer anywhere in the forum. Turns out the module works great!

    Tom Hogue

  13. Is it possible that after creation DAY/NIGHT index 0 ,it is automatically taking charge of inbound and only one particular road by it-self?
    I have not selected at all just created.
    Strange ha

Leave a Reply