Macro for Open door via Intercom


I am trying to understand the logic, please tell me if such thing is possible.

Basicallly, I am trying to open the intercom VIA Macro when a user press a button or call *00 to activate the macro, but I have issues with it.

I can open the intercom if I send DTMF “00”

The problem: It only works while there is a call.

My solution was to create a macro like this:

exten => *00,1,Answer
exten => *00,2,Dial(“SIP/6”,3,M(OpenIntercom))

exten => s,1,SendDTMF(00*)
exten => s,n,Hangup

But, I have a problem with it, I don’t want to disconnect call if there is already an active call to the intercom

scenario 1:
a human calls to a user in the company via intercom, the user wants to press open door button which do Speeddial to *00
what happens? the call is disconnected, and the doors opens

a human approach the door, the secretary opens the door by pressing speeddial key to *00, the door opens, perfectly.

I have problem with scenario1
the macro needs to detect, if there is an active call between Intercom and the user, If there is already, it just sends 00 to the active session.
if there is no active call, it dials to the intercom then it sends *00

But If I understand the logic, something like this can not be done ? Right?

The macro needs to work on Phone side an not on server side(I use Grand Stream phones)

I just want that it will not hangout / push to other line the call while the user wants to open the door, The user are dummies, I am setting them a key, they cant figure if they needs to press 00 while there is active call, or *00 while there is no call. I need to setup a button on the phone, that will do that.

Correct. You can’t have one button do two totally different things like that.

The proper way to do this is to tell the user ‘If they have called you through the intercom, dial when you’re in the call 00 to unlock the door. Otherwise push the button on your phone’.