Same extension, two SIP phones, allow only one to be used

I have a scenario that is highly specific. I have two SIP phones, one is a door speaker phone/intercom (SIP based) and the other is a handset with an ATA. The requirement is that the person at the door can use EITHER phone but not both, or if they try to switch, the one they aren’t using won’t work (or something along those lines).

I was thinking I might be able to solve this in Asterisk, where I define two SIP clients (one the speakerphone/intercom and the other the ATA for the handset), these both can show up as the same extension. But this is where I get stuck…

Is there a way to config extensions.conf or the like to where only one of the two SIP phones can be used at a time? I guess it would be where we would detect when one is in use, then don’t allow the other to even get past INVITE?

Even better would be like a “barge in” where if one is picked up, then the other can “barge in” over the top of it and replace it in the call.

Note: these are all setup as hotline dial phones doing extension to extension (basically a closed system within the Ast server.

Thanks,

Colin

You can use AGI and DB.
Then - when one phone makes a call - you can put some flag, and then you can send busy to the other if other try a dial also.
Important - you have to be sure you clean that flag after hangup - in hangup extension or some other way - or after first call - you will get only busy