Device States

There are two types of devices that device states refer to: real devices and virtual devices. Real devices are telephony endpoints that can make or receive calls, such as SIP phones. Virtual devices include things that are inside of Asterisk, but provide useful state information. Table 14.1, “Virtual devices in Asterisk” lists the available virtual devices in Asterisk.

Table 14.1. Virtual devices in Asterisk

Virtual deviceDescription
MeetMe:<conference bridge> The state of a MeetMe conference bridge. The state will reflect whether or not the conference bridge currently has participants called in. More information on using MeetMe() for call conferencing can be found in the section called “Conferencing with MeetMe()”.
SLA:<shared line> Shared Line Appearance state information. This state is manipulated by the SLATrunk() and SLAStation() applications. More detail can be found in the section called “Shared Line Appearances”.
Custom:<custom name> Custom device states. These states have custom names and are modified using the DEVICE_STATE() function. Example usage can be found in the section called “Using Custom Device States”.
Park:<exten@context> The state of a spot in a call parking lot. The state information will reflect whether or not a caller is currently parked at that extension. More information about call parking in Asterisk can be found in the section called “Parking Lots”.
Calendar:<calendar name> Calendar state. Asterisk will use the contents of the named calendar to set the state to available or busy. More information about calendar integration in Asterisk can be found in Chapter 18, External Services.

A device state is a simple one-to-one mapping to a device. Figure 14.1, “Device state mappings” shows this mapping.

Figure 14.1. Device state mappings

Device state mappings

Checking Device States

The DEVICE_STATE() dialplan function can be used to read the current state of a device. Here is a simple example of it being used in the dialplan:

exten => 7012,1,Answer()

; *** This line should not have any line breaks
    same => n,Verbose(3,The state of SIP/0004F2060EB4 is 
    same => n,Hangup()

If we call extension 7012 from the same device that we are checking the state of, the following verbose message comes up on the Asterisk console:

    -- The state of SIP/0004F2060EB4 is INUSE


Chapter 20, Asterisk Manager Interface (AMI) discusses the Asterisk Manager Interface (AMI). The GetVar manager action can be used to retrieve device state values in an external program. You can use it to get the value of either a normal variable or a dialplan function, such as DEVICE_STATE().

The following list includes the possible values that will come back from the DEVICE_STATE() function:




  • BUSY