Page 1 of 1

Smart BLF indicator for Time Condition?

PostPosted: Tue May 13, 2014 7:30 pm
by jnewkirk
Anyone done this or can nudge me in the right direction?

I have someone with a Time Condition set on their system but with intention to only use it manually - trigger by hand. So I set up a BLF button on their D50 to dial the designated code to toggle the menu, works fine.

but what I'd really like to figure out is how to trigger the LED on the assigned button to indicate Day/Night condition.

Do I need a Custom App starting at phone boot that toggles the lamp based on a query sent to asterisk, as I deduce? Or is there something simpler I'm missing?

if a custom app, which I'm not averse to working out, can someone point me at a couple starting points for the API query?

Thanks for any assistance.

Asterisk 11.8.1, AsteriskNOW, freepbx and CentOS updates.

j

Re: Smart BLF indicator for Time Condition?

PostPosted: Thu May 15, 2014 7:39 am
by malcolmd
Howdy,

I'm not a FreePBX expert, so I can't speak to how to implement this in FreePBX, sorry.

What you're looking to do is to create a custom device state within Asterisk, e.g.

Code: Select all
exten => daynightstate,hint,Custom:daynightstate


Then, you'll have the phones subscribe a BLF to that hint and dial an extension that controls that hint when someone presses the key.

Then, you'll do things to manipulate that state, e.g.

Code: Select all
exten => OpenAndClose,1,NoOp()
same => n,Answer()
same => n,Answer()
same => n,GotoIf($["${DEVICE_STATE(Custom:daynightstate)}" == "BUSY"]?setavailable:setaway)
same => n(setaway),Set(DEVICE_STATE(Custom:daynightstate)=BUSY)
same => n,Hangup()
same => n(setavailable),Set(DEVICE_STATE(Custom:daynightstate)=NOT_INUSE)
same => n,Hangup()


Cheers

Re: Smart BLF indicator for Time Condition?

PostPosted: Thu May 29, 2014 10:40 am
by jnewkirk
Thanks for your response. Unfortunately this got back-burnered by a few emergencies, but I revisited it yesterday. Your suggestion led me to seek a matching freepbx-friendly solution, and I soon realized that FreePBX already exposes the necessary hints, if told to do so. (with the 'bonus' that it reflects automatic toggles in Time Conditions as well as manual toggling) So here's where it ended up:

In FreePBX go to Settings->AdvancedSettings and ensure that "Enable Custom Device States" is set to True. (this sets it to expose hints for various aspects of the dialplan) (also note that you need to click the green checkmark that appears at the end of the line to apply the change - each change in Advanced Settings has it's own Apply button...)

Now create your Time Condition or Call Flow Control. (I ended up switching from TC to CFC because the user decided she wanted manual-only control, provided I could make the BLF work)

Note the feature code (*271, *280, whatever) assigned to the toggle, and head to the Digium Phones section in FreePBX, and go to Phonebooks.

Edit (create if needed) a phonebook and create an entry with 'Subscribe' checked, and the feature code used for both Number and SubscriptionURL, then assign that phonebook in the Phones via the 'Rapid Dial Key Phonebook' drop-down, save, apply, reconfigure affected phones.

At this point pressing the line button associated with this phonebook entry will toggle the time condition or call flow control, and the BLF lights green in one state, dark in the other. It also responds to scheduled changes in the Time Condition, so when it toggles automatically to 'night mode' at 6pm or whatever, the BLF reflects that.

Win.

Thanks again for the help, and for the phones, and for Asterisk...

j

Re: Smart BLF indicator for Time Condition?

PostPosted: Thu May 29, 2014 10:47 am
by malcolmd
Huzzah!

You're very welcome, and thank you for the follow-up :)