DAY/NIGHT toggle with cron

Discussion in 'General' started by Patrick_elx, May 9, 2009.

  1. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
    I wish there would be a module in freepbx or elastix to execute some actions on a time schedule without having to go manually play with the cron.

    The day/night mode toggle is great, but if you forgot to reset it, it's a mess the next day.

    One way is to have a cron job reseting the day/night at the time of the normal time condition change.

    I've seen that you can do a
    Code:
    /usr/sbin/asterisk -rx "database put DAYNIGHT C0 NIGHT"
    in a cron to change the toggle to Night. But by looking at the extensions_addition.conf I see that when we change it manually by the phone, there is also a
    Code:
    Set(DEVSTATE(Custom:DAYNIGHT${INDEX})=INUSE)
    Is this one important also to set with a cron job and what is the proper line command to do it?
     
  2. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Patrick:
    Time Conditions in FreePBX don't work for you ?
     
  3. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
    Let's have the following scenario:

    time group: open:9am to 5pm; close: 5pm to 9am
    time condition: open -> extension; close -> ivr


    now you want to work late one day. You create a day/night toggle.

    The inbound route will be:

    ->day/night: day -> extension; night -> time condition


    when someone works late, he toggles day/night to day and can continue to receive calls after 5pm. (This can be done also by associating day/night in the time condition tab, but that will not work with the further step below)

    But if he forgot to switch it off when leaving, the next night the toogle will still be day.

    I want to automatically switch the toggle back to night at 9am.



    Now let's go a step further: I want the secretary to switch to a 'night' mode during her variable lunch break. I will have to create a second day/night toggle

    day/night2: day -> extension; night -> IVR

    and change the inbound route with

    ->day/night: day ->day/night2; night -> time condition


    I will also need to be able to switch back day/night2 to day at the 5pm

    A cron job need to be created for that, but if you change the time group, you will have to remember to manually change the cron associated with it. That's where a module would be nice to associate some actions at the time group limits.


    Also, last but not least, you want to make sure that when someone toggle day/night to day that you reset day/night2 to day also. And there's no 'container/misc application' that will let you do it within freepbx.
     
  4. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    Or perhaps the primary condition is time condition and the night mode goes to day/night. the next time outside the time condition if the boss (and I assume it's the boss because nobody else is in the position of not being able to be trained) tries to override he will so be informed that he forgot to reset it last time , further the receptionist should be trained to verify proper day/night operation before she goes home and when she comes in, come on he/she already does his dry cleaning for him and gets his coffee, , because that's what we have to do with moronic bosses. You can script most things but if you try to script human behavior something will eventually go wrong, and when it does it will be your fault!

    (The cron job works does work though, I do it for one arrogant bastard, (he pays well))
     
  5. Patrick_elx

    Joined:
    Dec 14, 2008
    Messages:
    1,120
    Likes Received:
    0
    in fact I'm trying to do something much more complex for a specific applications on some specific route, but the scenario I've is a good summary of the part I have issue with.

    Does the cron needs also to set the DEVSTATE. For what is the devstate used for?
    Is the command line:
    Code:
    /usr/sbin/asterisk -rx "Set(DEVSTATE(Custom:DAYNIGHT0=INUSE)"
     
  6. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    I use

    rasterisk -x 'database put DAYNIGHT C0 DAY' > /dev/null

    (case sensitive where 0 is day/night index, into /dev/null so it doesn't piss you off everytime it runs in cron)

    rasterisk -x 'database show DAYNIGHT C0'

    to verify

    or
    rasterisk -x 'database show DAYNIGHT'

    to show them all

    (rasterisk is really 'asterisk -r' but checks to see if it's running first, it's just an elegant way to talk to a remote asterisk server, even if local!)

    {edit]

    I notice that my Aastra phone (true enough it's hacked to pieces with nine registrations and the side car monitoring everything but the time in Peking) takes some minutes to resync with the current day/night status so maybe you need to do some devstate stuff if a keen eyed receptionist is on duty when the cron job runs. (note to self, I wonder when will freeswitch become consumer grade? so we can move forwards)
     

Share This Page