FreePBX/ Asterisk on OpenHAB 3.1.0?

Hello, it seems that Asterisk is missing from

FreePBX is according to Wikipedia a web based GUI for Asterisk. It is a component of the FreePBX Distro. Does that cause any problems with the Asterisk binding?

Why is asterisk no longer mentioned on said page?

The Asterisk binding is an openHAB v1 binding. OpenHAB 3.0 (and higher) no longer support openHAB v1 bindings hence it is no longer listed on the addon page. You can still find it if you select 2.5 from the ‘Archived’ drop down menu.

Could a new binding that is supported in 3.0 and newer versions be developed?

Ps:
Some IP door cameras does support SIP and ONVIF.

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. :wink:

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…

Yes, would be very nice to have a recent version… and with much more options than to only get the caller ID…

1 Like

Slightly off topic:
Maybe there are better options for the GUI?
It is possible to use the built in one,-but I am unsure of the stability.
If it’s not included in the Ubuntu package wells:

There also are several others.

Possible options to Asterisk:

@Supermagnum out of curiosity why did you just copy all of the above out of my last post at Does OpenHAB handle IP cameras with two way audio? - #8 by digitaldan ? You didn’t even bother to follow up there . You have been cross posting about this stuff on our forum, our GitHub issue tracker as well as the jitsi-meet GitHub issue tracker. Please keep topics like this to a single thread.

1 Like