Do no Disturb - Automatic switch on/off

Hi !

Is there a way to configure Freepbx / Asterisk to have an extension be switched to DND from, say 5PM to 8AM next day ?

I looked through the GUI and could find such function.

Thanks !

No there isnā€™t but you can script it as a cron job to run at 5pm and 8am

Script you can use for the cron:

1 Like

Thanks sir. This is just amazing.
I will adapt and use.

@lgaetz: Thanks, that works very well.

Only drawback is that the Digium phones (D40, D50, D70) do not reflect the DND status with the picture of the DND extension on their screen (Rapid dial).

Do you have a trick to refresh that too ?

No, I donā€™t know how digium devices track dnd status.

Yealink phones allow remote control via SIP notify.

I use that to set DND from a script on the PBX in order to have the phone and the PBX be in the same status.

You could check if the Digium phones have a similar function.

As a diagnostic I would see if

rasterisk -x ā€˜devstate listā€™

(them rasterisk -x ā€˜devstate changeā€™ to see the rules)

and possibly

rasterisk -x ā€˜devstate change Custom:DND1234 {INUSE,NOT_INUSE}ā€™

has any effect on the phone.

@sorvani: Yes, this is what I am trying to do.
@dicko: I tried it, but no effect on the phone status nor the actual phone state. :frowning:

But thinking more about it, I guess a simple time group / time condition could do the job as wellā€¦

Thansk !

Well, it can easily create a schedule. Then you can make a custom context to cause the DND status to change, and have that linked to the time condition.

But that will not update the phone itself.

For Yealink, they accept key press commands via SIP Notify.

You can see in the FOP2 window that the phone is sending a *78 & *79 when it receives the notify. The phone also has its DND icon enabled, because this SIP notify command is telling the phone to press the DND button.

Peek%202019-11-30%2016-53

I did a little poking on google and I cannot find anything showing that Digium phones have this type of functionality.

@sorvani: I am under chan_sip and not PJSIP unfortunately.

I changed pjsip to sip but this is too simple to work. :slight_smile:

I will look through the wonderful world of the Internet to find some hints for that command you sent me !

Thanks much

I tried an asterisk -x ā€˜sip notify dnd-Digium 777ā€™ command.

it says that is notifying the phone extension but no change in status is apparent.

2 options:

  • missing an option somewhere
  • or Digium phones do not accept this type of commands (which I doubt, as fop2 manages to change the status phone)

developpingā€¦

@malcolmd: Malcom, Hi

If you have 5 mins, could you just give me an example on which command I could send through a command line to act upon what you wrote in the Status Application on [DPMA] (https://wiki.asterisk.org/wiki/display/DIGIUM/DPMA+Configuration)
?
I have:
[DndOff]
type=application
application=status
status=available

[DndOn]
type=application
application=status
status=dnd

Which config file should I put that in ? And which command should I make to swith, say extension 101 from available to dnd and vice versa ?

Thanks much !!

So hereā€™s my question, does the phone support BLF buttons? Because there are two types of DND there is normal DND which is at the phone level. So when you hit the DND button it makes the phone busy so it wonā€™t accept incoming calls regardless of line/account since it does it to the entire phone. This usage of it means the PBX doesnā€™t know the phone is DND and will still send calls to it and get back the 480/486 from the phone to say itā€™s busy.

The other type of DND is the DND at the PBX level, which changes the extension state to BUSY and sets flags in the system to show itā€™s DND and should not have calls sent to it. And based on that DND setting do other things.

These two types are not connected to each other since at the phone level, like I said before, is the entire phone. So if I have a phone with two accounts from two different PBX systems, then when my phone is DND (from the phone) then both accounts are BUSY. So neither PBX knows. Setting DND at the phone level does not set it at the PBX and vice versa. Using the SIP NOTIFY method allows them to set it at the PBX and then the notify tells the phone to turn on itā€™s DND.

While the SIP NOTIFY method will work there are some caveats. First being itā€™s not automated. So you would need to write custom dialplan to include on the DND on/off/toggle feature codes so that the proper SIP NOTIFY is sent to deal with the appropriate state. Second being the phones ability to accept the SIP NOTIFY, that shouldnā€™t be too much of an issue. Third would be the phones ability to make those changes and how fast it can make those changes. Normally a phone that is in use (line is open/ringing) wonā€™t apply changes until the phone is idle. So the phone needs to sit idle after the call to change DND states so it can accept the SIP NOTIFY and then apply the changes. Because if the SIP NOTIFY isnā€™t sent or accepted then the phone wonā€™t have DND (at the phone level) turned on or off depending on the action needed. Meaning the PBX will see the extension ā€œfreeā€ and send calls to it and get a BUSY response and send the call to voicemail because the PBX sees DND off but the phone never took the update or the NOTIFY didnā€™t send so the phone is still DNDā€™d itself.

Back to the BLF question because what you could do is just setup a BLF line to the DND hint for the extension and when you press the BLF button it will dial the PBX and toggle the DND state. So if the BLF button is green/off no DND if the button is red/on then DND is enabled. No extra dialplan, no need to trigger a SIP NOTIFY and no worries that the phone will accept that NOTIFY and update itself in a timely manner.

1 Like

Hi BlazStudios:

Thanks for the explanation. My phones are all Digium, accept BLF, and the assistant was supposed to supposed to press DND when we was leaving for the night. Which obviously she is forgetting half the times.

Thus the need to automate the process wether by time conditions which I do not master to be honest, or through a script which I prefer to be honest.

Thanks to @lgaetz, I can control the DND status at the PBX level, but I am still missing the ability to send the same status to the phone.

Thanks to @dicko and @sorvani, I could try some options but I did not manage to replicate the success on Digium vs. Yealink.

There is probably something to do through DPMA, and there it is @malcolmd expertise !!:slight_smile:

J.

https://wiki.asterisk.org/wiki/display/DIGIUM/Digium+Phones+when+used+with+DPMA#DigiumPhoneswhenusedwithDPMA-UserPresence

Also try "presencestate " from the Asterisk CLI and press tab.

1 Like

Thanks much. Very easy actually.

Not reflected in FOP2 but visible on the phone now.

Then that means at the Asterisk/FreePBX level the customdevice states and flags for DND are probably not set. There is a hint generated for the DND state/toggle feature code. That hint is what a BLF or other state monitoring would use.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.