Can not Set Custom Precense State

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

it’s saying its already loaded it:

remote-bx*CLI> module load func_devstate.so
Unable to load module func_devstate.so
Command ‘module load func_devstate.so’ failed.
[2018-06-04 22:29:12] WARNING[17192]: loader.c:1073 load_resource: Module ‘func_devstate.so’ already exists.

You need to fix your spell checker:

34693894*CLI> core show function DEVICE_STATE

  -= Info about function 'DEVICE_STATE' =-

[Synopsis]
Get or Set a device state.
1 Like

[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 ${DEVICE_STATE(SIP/100)})
exten => *15,n(hook_on_1),Hangup

Just did it like this and now shows nothing about device state:

Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
== Spawn extension (from-internal, *15, 7) exited non-zero on ‘SIP/300-00000005’
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/300-00000005’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/300-00000005’

IT SHOULD SHOWS IT IS IDLE:
remote-bx*CLI> core show hints

-= Registered Asterisk Dial Plan Hints =-

100@ext-local : SIP/100&Custom:DND10 State:Idle Presence:chat Watchers 0

How are you connecting to the from-internal-custom context? I don’t see it in your output.

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.

Did it with different feature code this time *3030 which is not part of dial plan. But receiving same responses.

Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
== Spawn extension (from-internal, *3030, 7) exited non-zero on ‘SIP/300-00000001’
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/300-00000001’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/300-00000001’

Sounds me there is another way to do it, will keep searching on forums too.

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