Smart BLF indicator for Time Condition?

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.



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.

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.

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()


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.


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



You’re very welcome, and thank you for the follow-up :smile: