I was puzzling over an issue on our VOIP phone system the other day, and have finally solved it so thought I'd share it with you and also for when I forget myself how I made it all work.
The problem: Have an option for users to add themselves in and out of their pre-defined queue, and to have a visual indication of if they are in or out of the queue on the phone handset (I also have wallboards, but it's nice to see on the phone handset itself)
Cisco SPA504G handset (Most newer Cisco handsets handle this too, unfortunately the older Linksys ones don't)
Asterisk - Freepbx 12.0.5 or newer (That's all I've tested)
Firstly, go into your Queue setup via freepbx webadmin and make sure "Generate Device Hints" is ticked for the queue. This will generate the function code *45EXT*QUEUE which is what we need for the phone to dial and jump in and out of a queue.
Then we need to tell the phone to allow you to dial such a weird function code. On the Cisco SPA504G web-panel, go into advanced and select EXT1 and go to the "Dial-Plan" option. You need to add in "*xxxxxx*xxxx" to this. My full dial plan shows "(*xxxx|*xx|*xxxxxx*xxxx|11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)" - this may or may not work for you too, but works for me!
Once you've saved that, try it by manually dialling *45EXT*QUEUE (change ext to be your extension number, and QUEUE to the queue you want to join/leave). You should get the asterisk voice confirming you've been added or removed from the queue.
(If you don't and get invalid extension on the phone screen, your dial-plan is still failing to pass it to asterisk)
Finally you can set the BLF button to show and control this. On the Cisco SPA504G these are the 4 line buttons to the right of the LCD. I'm using the bottom one for this.
Choose the PHONE tab on the Cisco SPA504G web panel, go down to LINE KEY 4 and set extension to DISABLED, then share call appearance to SHARED. In the extended function box, put in:
(Where *45 is the feature code setup in Freepbx, 5150 is the queue name. $AUTHID should be translated to the phone extension number and $PROXY to the asterisk server IP address)
After a reboot the display should show QUEUE against a green light on the 4th button. Press it, and it should log you into the queue (and hear the voice message) and then set the light to RED to show you as being logged in. Press it again and it should log you out and the light go back to GREEN.
(BTW in the photo you'll see I've actually assigned the QUEUE to button 3 as I use button 4 as DND indicator)