Interfacing to (Crestron) automation – long post

As part of my PBX project I plan to integrate the phone system to my Crestron automation system.

I’m pretty new to FreePBX so please excuse any dumb questions or statements. I have endeavoured to figure quite a bit of this myself but could do with a few pointers and help with trying to get FreePBX to communicate with the Crestron.

Below I’d like to outline what I have achieved so far and any pointers that you guys can give me so that anyone else who would like to implement similar functionality will have a good starting point.

Preamble – please skip to Main Section at the end if you don’t have time to read the whole post.

Current hardware:
1 x Raspberry Pi / FreePBX 14 (I will eventually run this on a dedicated Micro PC)
4 x Snom 821
Various mobile devices running Sipnetic softphone app
1 x X-Lite softphone running on MacBook Pro
3 x Crestron TSW-752 touchpanels with built-in SIP/Rava (integrated into my Crestron automation system)
2 x iPads running Crestron touchpanel app with built-in SIP/Rava
1 x Linksys SPA3102 trunk (currently not working)

Additional hardware to be implemented:

  • DECT to SIP base station – possibly looking at sticking with Snom but open to suggestions
  • 6 Snom DECT phones

The current specs of the system are as follows:

  • 2 doors with CCTV cameras and 12V door solenoids
  • Door entry from Crestron touchpanels – this is already implemented through the Crestron control system where the door solenoids are driven directly from the Crestron processor and video is displayed on the panels
  • Door intercom communicates currently with the Crestron touchpanels/iPads through SIP/Rava
  • Door intercom is able to ring all extensions (incl: Mobile softphone apps)

Currently when someone rings the intercom all extensions are called including touchapenls/iPads. Got that bit all figured out and works well. The tricky part is integrating the PBX to the Crestron.

The proposed operation is as follows:

  • Door rings
  • All extensions ring (apart from those that are in Do Not Disturb mode) and live video displayed on supported devices
  • On answer - touchpanels/iPads – 2-way coms to door with live video (already operational)
  • On answer – Snom 821 – 2-way coms to door with live video (I am able to display video on the phone but I’m struggling to get the Snom minibrowser to operate on a door event. I’ll work through that problem at a later stage in the project)
  • On answer – Snom DECT phones – 2-way coms to door (video is displayed on any TV that is currently on)
  • Door release – touchpanels/iPads – already implemented with a button press on these devices
  • Door release – all phones – Press #1 to open the doors only while the call is active

So, I’ve implemented some initial tweaks to FreePBX:

Here are my current configs of interest:

manager.conf – sets up the AMI telnet interface
[general]
enabled = yes
port = 5038
bindaddr = 192.168..
displayconnects=yes ;only effects 1.6+

[admin]
secret =
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0

;read=system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
;write=system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
;writetimeout = 5000

read = all
;write = all
write=system,call,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message

#include manager_additional.conf
#include manager_custom.conf

manager_custom.conf – set up permittable IP addresses
permit=192.168.10.3/255.255.255.0 – IP address of Crestron processor

manager_additional.conf
Currently empty

globals_custom.con – sets up keymaps for extensions
DYNAMIC_FEATURES=> mapgroup

features_applicationmap_custom.conf – setup automation and keymaps (from globals_custom.conf)
open01 => #1,caller,macro,executeOpen01
open02 => #2,caller,macro,executeOpen02

[mapgroup]
open01 => #1
open02 => #2

extensions_custom.conf – macros and automation
[macro-executeOpen01]
exten => s,1,Set(CURL(http://192.168.10.3:23,entry=1))
exten => s,2,Playback(custom/front_door_open)
exten => s,3,Wait(5)
exten => s,4,Hangup
;end [macro-executeOpen01]

[macro-executeOpen02]
exten => s,1,Set(CURL(telnet:"entry=2"))
exten => s,2,Playback(custom/back_door_open)
exten => s,3,Wait(5)
exten => s,4,Hangup
;end [macro-executeOpen02]

[automation]
exten => 1,1,Set(CURL(telnet:"entry=1"))
same => n,Return()
exten => 2,1,Set(CURL(http://192.168.10.3,entry=2))
same => n,Return()

For testing purposes I’ve setup two Custom Destinations in FreePBX:

  • Automation event 01
  • Automation event 02

Here is Automation event 01:
Target: automation,1,1
Description: Automation event 01
Return: Yes
Destination: Play Recording - > Front door open

Automation event 02 is nearly identical:
Target: automation,2,1
Description: Automation event 02
Return: Yes
Destination: Play Recording - > Back door open

Also, for testing I have created a custom IVR:

-IVR General Options
IVR Name: IVR automation

-IVR DTMF Options
Most of these settings are pretty standard, I can detail them if required

-IVR Entries
Digits: Destination
#1 Custom Destinations
Automation event 01 – Note this calls the Custom Destination as outlined above

#2 Custom Destinations
Automation event 02– Note this calls the Custom Destination as outlined above

#0 Play Recording
Thank-you & goodbye

I have also created a Virtual extension for testing functionality: Extension: 666

Main section – with questions

Currently my Crestron system is able to connect to the AMI interface on port 5038. It can log in and it is able to parse all the data coming out, and there is a lot.

My goal:

When either #1 or #2 is pressed during an active call to the intercom, I’d like to send the command ‘entry=1’ or ‘entry=2’ to the AMI port.

I have most of this working but I’m struggling to send the commands to AMI. Now I’m assuming that I’m misunderstanding the concept of Curl here and it’s probably not what I need.

If I dial extension 666, my IVR plays a simple recording and waits for either #1, #2 or #0

Pressing #1 will run the [automation] event:
exten => 1,1,Set(CURL(telnet:"entry=1"))
same => n,Return()

A view of the logs shows the event has run:

[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [dest-1@customdests:1] NoOp(“PJSIP/1104-00000043”, “Entering Custom Destination Automation event 01”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [dest-1@customdests:2] Gosub(“PJSIP/1104-00000043”, “automation,1,1()”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [1@automation:1] Set(“PJSIP/1104-00000043”, “CURL(telnet:“entry=1”)”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [1@automation:2] Return(“PJSIP/1104-00000043”, “”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [dest-1@customdests:3] NoOp(“PJSIP/1104-00000043”, “Returned from Custom Destination Automation event 01”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [dest-1@customdests:4] Goto(“PJSIP/1104-00000043”, “play-system-recording,3,1”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx_builtins.c: Goto (play-system-recording,3,1)
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [3@play-system-recording:1] Answer(“PJSIP/1104-00000043”, “”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] pbx.c: Executing [3@play-system-recording:2] Playback(“PJSIP/1104-00000043”, “custom/front_door_open”) in new stack
[2019-05-01 15:26:10] VERBOSE[16503][C-00000059] file.c: <PJSIP/1104-00000043> Playing ‘custom/front_door_open.slin’ (language ‘en’)
[2019-05-01 15:26:12] VERBOSE[16503][C-00000059] pbx.c: Executing [3@play-system-recording:3] Hangup(“PJSIP/1104-00000043”, “”) in new stack
[2019-05-01 15:26:12] VERBOSE[16503][C-00000059] pbx.c: Spawn extension (play-system-recording, 3, 3) exited non-zero on ‘PJSIP/1104-00000043’

1st question,
How can I send the text ‘entry=1’ to the AMI?
As neither CURL(telnet:"entry=1") or CURL(http://192.168.10.3,entry=2) is getting out of the port so there is some basic misunderstanding on my part. An example of the syntax would be great.

2nd question,
How do I limit the amount of data being sent to the AMI port?
This really is far to chatty for me and the sheer volume of data can drive an already busy Crestron processor to 100% CPU load.

At the moment I have
write=system,call,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message

in manager.conf but I assume that I can apply the necessary filters once I know what type of data I intend to send to the AMI (entry=1)

Possibly something like:
write=message

3rd question
Is it possible to read back a response from the Crestron?
I’d like to send something like ‘entry1=on’ or ‘entry1=1’ back to the PBX.
My apologies for the long post.

Regards

-slip

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