Delayed DTMF code for Door Relay

Hello,

Summary:
I would like to create an extension that when dialed will close a relay (open a door).

Current working setup:
I have a SIP endpoint (Snom PA1) that is registered as “800”. Currently when the endpoint is dialed, it automatically answers. When pressing “1#, 2#, 3# or 4#” the device closes relay 1 through 4 respectively. IE: Opens a door. All that is working fine.

What I would like to create:
Dialing extension 801 makes a call to extension 800, waits 1 second, dials DTFM code 1#, waits 1 second, hangs up call.
Then dialing 802 makes a call to extension 800, waits 1 second, dials DTFM code 2#, waits 1 second, hangs up call.
and so on.

I assume this can be done by editing the extensions_custom.conf file. But I’m stuck on what text string is needed. I assume it would be something like, but with a code that actually works.

exten => 801,1,Dial(SIP/800,,D(ww1#))

Thanks in advance for your input.

I’m not at a PBX right now, but something like
"Call the phone",
“Play Silence/2”,
“Dial 1##”
"Play Silence/2"
“Hangup”

This might also be a good application for a Call File.

My apologies if I didn’t describe my end goal well.

My end goal is I want to have 4 custom extensions that will unlock 4 separate doors.

My relay endpoint (Snom PA1) has 4 different relays that will be used to unlock 4 different doors. This is already installed and working. I can dial 800, then wait for the auto answer in under 1 second, then dial the DTMF code for relay 1 through 4 that corresponds to the door 1 through 4.

My thought is to create a custom extension that then calls a real extension that dials a DTMF code to unlock the door. I need to create 4 different custom extensions that when dialed, will call the same endpoint (at ext 800) BUT with a different DTMF code for unlocking the 4 different door (relays). IE: 801 opens door 1, 802 opens door 2, etc.

I know what I want to do and it’s probably a super easy line of code, I just don’t know how to actually write this in extensions_custom.conf file?

Call ext 801
then call ext 800
wait 1 second
then dial DTMF code 1#
wait 1 second
hang up

1 Like

If you use my suggestion, you will do exactly what you said you want to do.

Something like this might work (I don’t know if the DTMF files are there, so YMMV).

exten=>801,1,NoOp(Opening Door 801)
exten=>801,n,Dial(SIP/800)
exten=>801,n,Play(silence/2)
exten=>801,n,Play(DTMF/1)
exten=>801,n,Play(DTMF/#)
exten=>801,n,Play(Silence/2)

There’s also this example lifted from a simple Google search:

[macro-door-801]
exten => s,1,Wait(1)
exten => s,n,SendDTMF(1#,200)
exten => s,n,Wait(1)

[macro-door-802]
exten => s,1,Wait(1)
exten => s,n,SendDTMF(2#,200)
exten => s,n,Wait(1)

[open-doors]
exten => 801,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN})
exten => 801,n,Dial(SIP/800,M(door-801))
exten => 801,n,Hangup()
exten => 802,1,NoOp(IN CALL : ${CALLERID(num)} => ${EXTEN})
exten => 802,n,Dial(SIP/800,M(door-802))
exten => 802,n,Hangup()

Change the [open-doors] context to one that gets included in your dial plan, and you should be on your way.

Dave,

This is perfect!

I’m still learning how the custom extensions work so this is very helpful.

Thank you.

Remember - this isn’t tested code. I am working off the top of my head since I don’t have access to a FreePBX system here. You may need to tweak a few things and there may be syntax, spelling, or alternate reality errors…

Did you ever test this or implement successfully? We have a similar setup and would love to hear the outcome and any other challenges you had.

Thanks in advance!

Sean

Since he never asked again, I’d say “Dave for the Win!”.

Seriously, there’s no downside to trying either of the solutions I suggested and seeing if one or the other works. Hey, if you do that, maybe pop back and tell us if it worked!

1 Like

Sean,

Yes, this setup works perfectly for our needs for almost 3 years.

We are using a Snom PA1 with Firmware 8.7.3.25.9. On the Snom PA1 under Setup -> Preferences -> PA1 Controls we have “Phone ends call after set seconds: 2” and “Pin 1 through 4” set to “off” and each off timer set to 1 second.

On the FreePBX under "Admin -> Config Edit -> extensions_custom.conf
[door_1]
exten => talk,1,Dial(SIP/800,D(ww1#))
same => n,Wait(2)
same => n,Hangup

Then "Admin -> Custom Destinations -> “Add Destination”
Target: door_1,talk,1
Description: door_1

Then "Applications -> Extension -> Create Virtual Extension ->
The extension you want to use to activate the relay
Under Advanced -> Optional Destinations
For “No Answer, Busy, Not Reachable” select “Custom Destinations -> door_1”

Rinse and repeat.

Hope all of these steps make since. :slight_smile:

1 Like

Hey! I realize this is now 2 years later that I’m finally trying this out…

I am using the SNOM PA1 in a slightly different way. Ours is registered on a PJSIP extension 35999. Pin 3 is attached to an input on our access control system. Upon closure, the access control system activates a strobe light at our emergency operations center to signal a panic button press at our district court building. I have verified that part is operating correctly by manually dialing the SNOM and dialing 3#. Now, getting it to work correctly with FreePBX using your advice…I’m hitting a roadblock and I’m certain I am that roadblock! :rofl:

I’ve mirrored your settings on FW 8.7.5.75.

I have:

[DC_Panic]
exten => talk,1,Dial(PJSIP/35999,D(ww3#)) <-----(I have tried SIP and PJSIP)
same => n,Wait(2)
same => n,Hangup

I have:
Target: DC_Panic,talk,1
Description: DC_Panic

Here’s the difference between ours. I used a PJSIP extension for the SNOM PA1 since it was a physical endpoint. Will I need to use a Virtual for this to work?

I did this at the 35999 PJSIP Extension.

Thank you in advance!

D(ww3#) is not a valid number of seconds for the timeout. You need an extra comma to provide a placeholder for the timeout.

Thank you for replying. Would you elaborate a tad more? Where should this extra comma go?

In FreePBX you usually want to dial the local channel instead of using the device signaling directly. So with david55’s correction, your dial string wants to look something like this:

Dial(local/[email protected],,D(ww3#))

image
Does this look correct?

Timing is important the ‘w’ is a 500 msec pause ‘ww’ a one second pause. . . .

What is the purpose of the wait?

Does the device hang up the call after receiving the command?

The SNOM PA-1’s primary purpose is public announcement. Unless I have overlooked the setting, it defaults to an audible 1000msec tone prior to broadcasting any audio from the caller. I’m adding the pause to compensate for that tone.

to prevent a race condition, try www (1500 ms) ?

But you are not waiting until the call is over. I think you are under a common misunderstanding that control is returned once the call has been set up; it isn’t; Dial continues to run for the whole call.

The device is set to hang up after 5 seconds but it isn’t.
image

I created a Misc Application to point to the DC_Panic Custom Destination.

When I dial *0911 using the code below, the PA1 doesn’t pick up the call immediately like it did in earlier attempts. Now it rings once, picks up and the DTMF never gets entered.

[DC_Panic]
exten => talk,1,Dial(local/[email protected],,D(wwww3#))
same => n,Wait(2)
same => n,Hangup

Here are the only changes I made to the 35999 PJSIP extension:

Here is a full call trace:
https://pastebin.freepbx.org/view/b91a451f

The part where the DTMF is ‘being sent’ supposedly begins around line 260. What am I missing? I did try adding a third and a fourth comma for longer delay, however, the Sending DTMF ‘www3#’ doesn’t show in the trace.

Thank you, gentlemen, for your help thus far.