The asterisk Binding was built in OH1 and therefor is/was an openHAB1 Binding. It was never recreated as an openHAB2/3 Binding.
In question of FreePBX, I had some success with a configuration, but it was not very stable (crashed about once a day), and it was not that easy to get it up and running, as the asterisk Binding uses the AMI (Asterisk Manager Interface) and I did not find the correct docs for how to configure FreePBX ācorrectlyā.
I tried various modules to create an mqtt client inside FreePBX.
Now Iām using a CID-SuperFecta Plugin to write Caller Information directly to mqtt. Iāve written the Plugin and also tried to get it to the official Repository, but I never got the software agreement correct. 
Simply
- install mosquitto_sub in FreePBX,
- install SuperFecta and
- add the file as
source-Send_to_MQTT.module
to /var/www/html/admin/modules/superfecta/sources/
.
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* Developer Notes:
*
* Version History
* 2020-10-14 Initial creation by hartmann1970@gmx.de
* 2020-10-15 added user, password, clientID by hartmann1970@gmx.de
*
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/
class Send_to_MQTT extends superfecta_base {
public $description = "This source will send CID number and name to an MQTT topic for external processing. The MQTT topic is added with DID and payload is JSON format. To use this feature, mosquitto has to be installed.";
public $version_requirement = "2.11";
public $source_param = array(
'MQTT_broker' => array(
'description' => 'Specify FQDN or IP of MQTT broker. Use the format \'this.is.org\' or \'192.168.123.045\'',
'type' => 'text',
'default' => "10.0.0.10"
),
'MQTT_port' => array(
'description' => 'Specify the port of the MQTT broker. Use the format \'1883\'',
'type' => 'number',
'default' => "1883"
),
'MQTT_topic' => array(
'description' => 'Specify the topic to send CID/CNAM data to. Use the format \'this/is/my/topic\' without trailing slash.',
'type' => 'text',
'default' => 'freepbx/calls'
),
'MQTT_user' => array(
'description' => 'Specify the user. Neither spaces nor special characters allowed.',
'type' => 'text',
'default' => ''
),
'MQTT_password' => array(
'description' => 'Specify the password. Neither spaces nor special characters allowed.',
'type' => 'text',
'default' => ''
),
'MQTT_clientID' => array(
'description' => 'Specify the ClientID. Neither spaces nor special characters allowed.',
'type' => 'text',
'default' => 'freePBX'
),
'Default_DID' => array(
'description' => 'In cases where DID is unknown, substitute this string in its place.',
'type' => 'text',
'default' => 'Unknown'
)
);
function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) {
if (($run_param['MQTT_broker'] != '') && ($run_param['MQTT_topic'] != '') && ($first_caller_id != '')) {
$port = ' -p '. $run_param['MQTT_port'];
$broker = ' -h '. $run_param['MQTT_broker'];
$user = "";
if($run_param['MQTT_user'] != ''){
$user = ' -u '. $run_param['MQTT_user'];
};
$password = "";
if($run_param['MQTT_password'] != ''){
$password = ' -P '. $run_param['MQTT_password'];
};
$clientID = ' -i '. $run_param['MQTT_clientID'];
$from_did = "";
if(isset($this->trunk_info['dnid'])){
$from_did = $this->trunk_info['dnid'];
} elseif (isset($run_param['Default_DID']) && $run_param['Default_DID'] != "") {
$from_did = $run_param['Default_DID'];
} else {
$from_did = $this->source_param['Default_DID']['default'];
}
$topic = ' -t '. $run_param['MQTT_topic']. '/'. $from_did;
$payload = ' -m \'{"number": "'. $thenumber. '","name": "'. $first_caller_id. '"}\'';
$this->DebugPrint("Send to MQTT broker : {$broker}");
$this->DebugPrint("Send to MQTT topic : {$topic}");
$this->DebugPrint("Send to MQTT payload: {$payload}");
$this->DebugPrint("Send to MQTT did : {$from_did}");
$command = 'mosquitto_pub'. $broker. $port. $user. $password. $clientID. $topic. $payload;
$this->DebugPrint("Send to MQTT command: {$command}");
$output = shell_exec($command);
$this->DebugPrint("Send to MQTT result: {$output}");
$value = $output;
}
}
}
In SuperFecta Configuration, activate Send to MQTT and put it as the last active service (or at least after the last service to get caller Information).
And configureā¦