How to know when a phone is available?

Hi,

is there a good a way (from within the dialplan) to find out if an AOR (i. e. a phone) is currently available, perhaps with an AGI script? ‘Available’ means it would show as “Avail” in the output of a command like ‘pjsip show contacts’.

The idea is to make it so that when certain phones are not available, calls to a particular phone will be automatically diverted to a different phone, according to a list of possible alternative phones to call. ‘Phones’ also means ‘the particular person someone wants to call’ because each person will have a phone assigned.

Or is there perhaps a better way to achieve this than tracking the availability of phones?

This is with asterisk Asterisk 16.28.0~dfsg-0+deb11u7.

Thanks, I got something to work by checking the device state.

How would you check a channel when the device isn’t available? That doesn’t make sense.

If it’s not available, then ChanIsAvail can’t create a channel.

You could also check out presence Presence State - Asterisk Documentation