The phones are also used as intercoms (bidirectional page).
To start, we need accounts for the phones/speakers added to sip.conf:
[phone1] ; Phone
type=friend
host=dynamic
context=my-context
secret=5678
mailbox=319
[speaker1]; Speaker
type=friend
host=dynamic
context=my-context
secret=1234
mailbox=329
record_out=Adhoc
record_in=Adhoc
qualify=no
Then in extensions.conf, in the [my-context] context, add:
; Paging extensions
exten => 3319,1,GotoIf($[ ${CALLERID(number)} = 319 ]?skipself)
exten => 3319,1,SIPAddHeader(Alert-Info: info=<intercom>) ; Digium D6x require this to enable paging - search documentation for different phone models!
exten => 3319,n,Dial(SIP/phone1) ; this is the phone1 defined in sip.conf
exten => 3319,n(skipself),Noop(Not paging originator)
exten => 3329,1,GotoIf($[ ${CALLERID(number)} = 329 ]?skipself)
exten => 3329,n,Dial(SIP/speaker1,50) ; this is the speaker1 defined in sip.conf
exten => 3329,n(skipself),Noop(Not paging originator)
exten => 398,1,Page(LOCAL/3319@my-context&LOCAL/3329@my-context,di,120) ; Bidirectional PAGE - that's what the "d" does.
exten => 398,n,Hangup()
With this, we can dial 398 and the PAGE should work.
Now, in order to say the time automatically, we need a .call file, let's create /var/lib/asterisk/third-party/say-time.call
Channel: LOCAL/398@my-context
MaxRetries: 10
RetryTime: 5
WaitTime: 20
Context: page-say-time
Extension: 3310
Of course, we need to create the [page-say-time] context in extensions.conf:
[page-say-time]
exten => 3310,1,Answer()
exten => 3310,n,Wait(1)
exten => 3310,n,Playback(at-tone-time-exactly) ; this sound file is already in asterisk sounds
exten => 3310,n,Wait(1)
exten => 3310,n,SayUnixTime(,EST,IMp)
exten => 3310,n,Wait(1)
exten => 3310,n,Playback(beep) ; this sound file is already in asterisk sounds
exten => 3310,n,Wait(2)
exten => 3310,n,Hangup()
and the last step, create a crontab that copies the say-time.call to the astersk outgoing at every fix hour:
0 * * * * /bin/cp /var/lib/asterisk/third-party/say-time.call /var/spool/asterisk/outgoing/