Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


HC2 and FreePBX last caller info. Got it working :-)


Guest

Recommended Posts

Not sure if anyone here is interested, but after some work I've managet to get my HC2 to pull the last callers ID (number) from my FreePBX system

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

 

Basically you will need to install "Caller ID Superfecta" (

Please login or register to see this link.

 ) on FreePBX, and configure the "Send to URL" part to push the callers info to a server (in my case the FreePBX server).

With some simple PHP code on the server the "pushed" callers info will then be saved as a json formatted text file.

 

Within HC2 create a VD to read the saved json formatted text file, and voilà.. The last dialed number will show up in your VD

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

 

Screenshot_2015-12-02-16-45-00.jpg

Link to comment
Share on other sites

Guest,

 

Thank you for you post. I have installed CID Superfecta on my FreePBX.

 

I would appreciate if you elaborate more on the next steps of implementation. Kind of step by step guide would be useful as well as the code for your VD.

Link to comment
Share on other sites

  • Topic Author
  • I'm about to go to bed now, so I will post my example tomorrow.

    Link to comment
    Share on other sites

  • Topic Author
  • SEE POST 14 FOR AN UPDATED VERSION!

     

    Lets assume that your FreePBX server is using IP 10.0.0.4

     

    (1) - You will need to setup CID Superfecta to use Send to URL.

    The URL entered in the box needs to look like this:

    Please login or register to see this code.

    Also make sure that you have setup CID Superfecta as show in the howto (

    Please login or register to see this link.

     )

     

    (2) - On the FreePBX server (10.0.0.4) create in the /var/www/html directory the file number.php, and put the following PHP code in it.

    Please login or register to see this code.

    The PHP code will create a JSON layout text file named number.txt when the "push" comes from CID Superfecta.

    Please login or register to see this code.

    To check if the file has been created access it like so:

    Please login or register to see this code.

    This should show up like this:

    Please login or register to see this code.

    (3) - All needed now is to create a VD with (for now) 1 label in it.

    Make sure that the ID of the label is: Label1

    Also make sure that the "172" in the code below corresponds with your VD ID

     

    Use the following code in the Main Loop

    Please login or register to see this code.

    Done.... Now with a bit of luck the VD will read the number.txt file and show it in the Label1.value

    Link to comment
    Share on other sites

    Guest,

     

    I have followed your guidance and at stage (3) I see the proper debug showing the content of the number.txt imported from FreePBX - so more less it is working, but :

     

    1. what is the number "172" in the line fibaro:call(172, .......)

     

    2. I think there is some setting to be adjusted in Superfecta as it seems to send out only CALLER ID which is present in the FreePBX phonebook. If the number is not present in the FreePBX phonebook, then nothing is send out from Seperfecta. I had no time to figure it out yet, but maybe you have any hint

     

    3. You have nice looking VD with caller number and the name - maybe you would like to share it  ...

     

    thank you for your useful almost ready made solution

    Link to comment
    Share on other sites

  • Topic Author
  • The 172 correspond's with the ID of my VD.

    You will need to adjust this according to your VD id.

    Sorry. I forgot to mention this.

    I've no clue why your Seperfecta is not sending the number when not present in the phonebook.

    Seperfecta does have a debug option. Try it.

    Also. You can select something like single and double processing. Try switching the process and try again.

    I will post the rest of the script later today ( I'm typing this on my mobile phone )

    Link to comment
    Share on other sites

  • Topic Author
  • To get the "name" shown you will need to add some extra lines and an extra Label in the VM.

     

    (1) - Add a Label to your VM and name is Label2

     

    (2) - Add the following extra code to your VM. Add it below the line:

    Please login or register to see this code.

    Code to add:

    Please login or register to see this code.

    ** NOTE: You will need to change the 172 to your VM's ID

     

    As you can see, the name's and umbers are hard coded! You will need to do this for all who you would like to show up!

    Link to comment
    Share on other sites

    Hi Guest,

     

    Here is what I achieved :

     

    I am progressing. The VD is working fine.

     

    I needed some time to figure out where to find the VD ID - it was only at HTTP address line.

    Second thing I resolved was that first I defined button on my VD and it was blank, I replaced it with label and then it started to show the number.

     

    The problem I have to resolve is that the file number.txt is updated only if the caller number is present in Asterisk phonebook. If it is not there, then the number.txt is not updated.

    I guess the problem is within number.php as this one writes to number.txt.

     

    I removed the module phonebook from my asterisk, but then number.txt was not updated at all.

     

    The other thing is that the solution with the list of the names you proposed is not very elegant.

    It would be nicer to have the database of the numbers and names with Asterisk phonebook and import from there the records to Fibaro.

    I need to work on it but the problem is lack of time.

     

    Anyway, I am not in rush but I hope we might work together to fine tune your nice solution.

     

    Marcin

    Link to comment
    Share on other sites

    A little update from my end on debug :

     

    As for now 

     

    - PUSH  http://10.0.0.4/number.php?thenumber=1234567890   works fine if I enter it manually in the web browser address field

     

    - the file number.txt is always reflecting what was pushed manually

     

    - Superfecta sends out the CID to number.txt (via HTTP push) only if it is present in the Asterisk address book

     

    - Superfecta does not update number.txt if the caller ID number is not present in the Asterisk address book

     

    I did my tests using the debug function of superfecta and the log shows that the push was properly send to HTTP

     

    Another thing is that I configured Superfecta to send an email with Caller data, but it is also not working - but the debug log confirms that the email should be sent.

     

    I will keep working on it as time allows ...

     

    Marcin

    Link to comment
    Share on other sites

  • Topic Author
  • I've set Processor to MULTI in my Superfectra. Did you test this option?

    Link to comment
    Share on other sites

    I tried both SINGLE and MULTI. Multi in my case was processing significantly slower than Single.

     

     

    What version is your Superfecta ?

     

    On what hardware do you run your FreePBX ?

     

    Mine runs on raspberry PI.

    Link to comment
    Share on other sites

    I am glad to share I managed to make it working.

     

    To have it done for numbers from Asterisk phonebook and also for others not listed I had to enable "Abandon Lookup" source in Superfecta.

     

     

    The next step (as time allows) will be to nicely integrate HC2 in the way that it shows names which are send from FreePBX along with the number rather to lookup for the names in the code of VD.

    Link to comment
    Share on other sites

  • Topic Author
  • Good to hear that you got it working!

    In my setup I've not enabled this option.

     

    I'm not using the Phonebook option within FreePBX, and as I do not have a lot of friends (

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" /> ) it's easy for me to "hard code" the name's with the numbers in the main loop.

     

    PS: I've got my FreePBX running as a VM on a VMware vSphere server.

    Link to comment
    Share on other sites

  • Topic Author
  • Okay.. Big update.

     

    I've now managed to "receive" the pushed number from CID Superfecta directly into a variable within HC2.

    So no more need to use the PHP script to create the JSON formatted number.txt file on the FreePBX server.

     

    Lets assume that your FreePBX server is using IP 10.0.0.4, and your HC2 is using 10.0.0.112

     

    (1) Create on the FreePBX server in /var/www/html a new PHP file with the name pushnumber.php, and put the following code in it:

    Please login or register to see this code.

    (The above code will PUSH the NUMBER value send by CID Superfecta directly to a variable named "LastCall" within HC2)

     

    (2) Setup CID Superfecta to use "Send to URL", and use the following URL in it:

    Please login or register to see this code.

    Tip from gucio1234: also enable "Abandon Lookup source" within CID Superfecta
     

    (3) Create a variable in HC2 (Panels > Variables Panel) with the name LastCall . (leave the value of it: 0)

     

    (4) - Create a VD with (for now) 1 label in it. Make sure that the ID of the label is: Label1

    Also make sure that the "172" in the code below corresponds with your VD ID

     

    Use the following code in the Main Loop

    Please login or register to see this code.

    That's all...

     

    If all is working fine, than you can delete the old "number.php" and number.txt" (see post 4)

    Link to comment
    Share on other sites

    Guest,

     

    I will test your updated solution (as time allows) and I will leave my feedback here.

     

    I like the new approach with updating the global variable.

     

     

    I do not like much that the VD is constantly checking the caller ID as I would rather to make an action only at the time when actual calls is coming.

     

    And here is my future idea how to get my Caller ID for HC2 :

     

    Asterisk is pushing the values to three global variables:  CID_Name, CID_Number, CID_Flag

    where

    CID_Name has the name of the caller pulled out from the Asterisk Phonebook or the word UNKNOWN if there is no entry in the phonebook

    CID_Number has the incoming caller's number

    CID_Flag is set to 1 when Asterisk sends out the data to variables of HC2 when there is an incoming call.

     

    The above can be done with your recent approach and Superfecta.

     

     

     

    Then on HC2 side the change of the variable CID_Flag from 0 to 1 activate the scene where you can do whatever you want with the information of the new incoming caller number and the name (eg. display it on your TV screen) and the scene will change the CID_Flag back to 0, so the scene will be inactive until there is next call coming which change the CID_Flag from 0 to 1.

     

    Any comments to my idea are welcome .....

    Link to comment
    Share on other sites

  • Topic Author
  • Hi gucio1234,

     

    No need to use a CID_Flag for an action (popup, or whatever)

    All you need to do is compare the new number with the old one.

     

    Something like this will work:

    Please login or register to see this code.

    Link to comment
    Share on other sites

  • Topic Author
  • Rethinking things here...

     

    What if same caller calls again... With the above code it will not work :/

     

    Maybe we do need a CID_Flag option after all, or add some kind of timestamp option to the above compare code.

    Link to comment
    Share on other sites

  • Topic Author
  • @gucio. 

     

    I've got all of your requests working

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

     

    I will post an update later as I need to cleanup the code a bit more, and I have another project that needs to be finished today.

    Link to comment
    Share on other sites

    Guest,

     

    There were no requests from my end , just the open idea and my roadmap of fine tune this project.

     

    As I had to focus on something else than Fibaro I had no time to be involved more than my comment above.

     

    Anyway I am looking forward for your input  ... as you said you focused on it already.

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...