I have the following in extensions.conf
exten => 799,hint,DS/mmgc
exten => 799,1,Macro(open-close,mmgc,open,closed)
exten => 799,n,Playback(beep)
exten => 799,n,Hangup
I define a button, for instance, on a Polycom or a Grandstream to speeddial 799 along with a hint. Ext 799 calls a macro the first item is, of course, the macro name, the second is the company (we have multiple companies), the third is a voice prompt for the open message (played so the user knows he/she is opening the business) and the last is the closed message.
The macro included in extensions.conf:
[macro-open-close]
exten => s,1,Set(nightmode=${DB(nightmode/${ARG1})})
exten => s,n,NoOp(ARG1 ${ARG1} ARG2 ${ARG2} ARG3 ${ARG3})
exten => s,n,Set(OpenFile=${ARG2})
exten => s,n,Set(CloseFile=${ARG3})
exten => s,n,NoOp(Close file ${CloseFile}. Open file ${OpenFile}.)
exten => s,n,GotoIf(${nightmode}=1?s,Open:s,Close)
exten => s,n(Open),Set(DB(nightmode/${ARG1})=0)
exten => s,n,Devstate(${ARG1},0)
exten => s,n,Playback(${OpenFile})
exten => s,n,Goto(Return)
exten => s,n(Close),Set(DB(nightmode/${ARG1})=1)
exten => s,n,Devstate(${ARG1},2)
exten => s,n,Playback(${CloseFile})
exten => s,n(Return),NoOp
I have since learned that instead of creating my own database entries, DevState creates database entries. For example, in this setup when the company is closed, there is a database entry for DEVSTATE/mmgc of 2. I haven’t modified the macro to use that.
It’s a pretty simple setup, when the company is closed, the DevState is set to in use, which causes the light to come on. When open, the light is off. My IVR checks the database to see if the company is open or closed.
As it is, I can remotely open or close the company via ssh into Asterisk and manually changing the database. But, it doesn’t show on the phone. If I were to use the database entry for DevState, I believe that would update the status on the phones. I think this would be the better way to go. In my 1.4 series deployment, I’ll probably make that change. I have to change my original macro anyway. My original macro uses commands that were depracated and now no longer available. This macro was updated to work on 1.4.