Hi, Im trying to set device state based on presence state but freepbx does not retrieve the presence state and also can not set dev-state.
Im altering Extensions_custom: [ext-local-custom]
I tried to use this code from Wiki but also did not work:
[ext-local-custom]
exten => 2000,1,Answer()
same =>n,Set(CURRENT_PRESENCE=${PRESENCE_STATE(CustomPresence:Bob,value)})
same => n,GotoIf($[${CURRENT_PRESENCE}=available]?set_unavailable:set_available)
same => n(set_available),Set(PRESENCE_STATE(CustomPresence:Bob)=available,)
same => n,Goto(finished)
same => n(set_unavailable),Set(PRESENCE_STATE(CustomPresence:Bob)=unavailable,)
same => n(finished),Playback(queue-thankyou)
same => n,Hangup
exten => 2001,1,GotoIf($[${PRESENCE_STATE(CustomPresence:Bob,value)}!=available]?voicemail)
same => n,Dial(SIP/Bob)
same => n(voicemail)VoiceMail(Bob@default)
Check the /var/log/asterisk/full log and make sure your extension and code are actually getting executed. One suggestion is to use a “NoOp” function on priority ‘1’ so you can easily spot the code in the logs.
Thanks cynjut, just did that but now sent me an error after doing :
[from-internal-custom]
exten => *15,1,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => *15,n,Answer()
exten => *15,n,SayDigits(${CALLERID(number)})
exten => *15,n,Wait(1)
exten => *15,n,SayDigits(${DEVICEUSER})
exten => *15,n,NoOp(SIP/mypeer has state ${DEVSTATE(SIP/100)})
exten => *15,n(hook_on_1),Hangup
---------------------------------------IT DOES what its should but looks like there is no module loaded for DEVSTATE BUT CAN NOT SEE WHERE TO LOAD IT--------------------
ERROR[16928][C-0000000c]: pbx_functions.c:593 ast_func_read: Function DEVSTATE not registered
Im using extensions_custom, but yes there is not any output like last time and dont know why. Can you replicate in your PBX and see if it works for you please so i can be sure is not a server isssue
OK - We know from your log extract that there’s a “*15” in your dial plan already, probably as a ‘standard’ part of the extensions_additional.conf file.
There are two possible ways to overcome that. The first is to define a new feature code for your presence setting button. The second would be to move this code to “extensions_override_freepbx.conf” (check the name - that might be exactly the right file) and define “*15” there.
Of these, obviously, choosing a different feature code will be the safest and easiest.