Do no Disturb - Automatic switch on/off


(France) #1

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 !


(Tom Ray) #2

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


(Lorne Gaetz) #3

Script you can use for the cron:


(France) #4

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


(France) #5

@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 ?


(Lorne Gaetz) #6

No, I don’t know how digium devices track dnd status.


(Jared Busch) #7

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.


#8

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.


(France) #9

@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 !


(Jared Busch) #10

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.

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


(France) #11

@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


(France) #12

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…


(France) #13

@mdavenport: 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 !!


(Tom Ray) #14

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.


(France) #15

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 @mdavenport expertise !!:slight_smile:

J.


(Malcolm Davenport) #16

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.


(France) #17

Thanks much. Very easy actually.

Not reflected in FOP2 but visible on the phone now.


(Tom Ray) #18

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.