External command to stop phone ringing

A video phone causes multiple systems to start ringing, when somebody at the door presses the button.

It rings FreePBX inbound route, but also (separately from FreePBX) mobile apps and Home Assistant (not really a SIP call, just an event).

When the mobile apps take the call, FreePBX stops ringing, which is fine. But for Home Assistant it doesn’t work that way, so when I take action, I can still hear FreePBX ringing until it gives up due to a call timeout.

So my question is just this: How can I instruct FreePBX to stop ringing immediately, without taking the call?

I can get things to execute on the FreePBX server, so any bash command or asterisk command would be feasible.

This might work, although I’m not sure how well it deals with a channel in the RING state:

There may also be a CLI channel redirect, that could send it to dialplan, to hang it up, and there are AMI equivalents of the latter, and possibly also the former.

In all cases you are going to have to look up the channel instance name.

1 Like

Ok… this seems to work:

asterisk -rx "channel request hangup $(asterisk -rx 'core show channels' | grep '/225-' | sed 's/|/ /' | awk '{print $1}') "

Breaking that up in parts for anyone interested:

  1. asterisk -rx 'core show channels' gets the output of show channels, where each ongoing call will have a couple of lines like this:
    PJSIP/225-00002153 s@macro-dial-one:59 Up Dial(PJSIP/221/sip:[email protected]

  2. | grep '/225-' | sed 's/|/ /' | awk '{print $1}' selects the line I want, that 225 used for the grep is the extension number that I am interested in. Then the sed and awk Marvellous Duo :tm: :dancing_men: picks the first column with the channel name such as 'PJSIP/225-0000214f.

  3. That result is inserted into the channel request hangup command. And the call is terminated :bomb:

Brilliant! Thank you @david55 once again :tada:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.