0

2N HTTP API

Ricardo Pinto | visiontech pt 3 weeks ago updated 3 weeks ago 1

Hello,


I was asked a challenge, about a 2N Doorbell installed recently.


I'm using both relay and output on the 2N unit, so I don't have any outputs available to do the following:


The client is asking if it's possible to ring an outside bell on the garden, when the 2N doorbell is ringing.


According to the 2N HTTP API, section 5.71 api call status, it looks like it's possible.


My goal would be to intercept the "ringing" state and therefore turn an KNX output with a bell for some seconds, or pulse the output to simulate bell ring.


I could constantely pool /api/call/status, but has someone a better ideia?


Right now I'm testing with a Http node, pooling the "result.sessions[0].calls[0].state" or "result.sessions[0].state" tokens, and I can get the string "ringing" as result. The problem is that after the call hang up the string remains. I was expecting the string to be empty after the call hang up, and according to the Json response is in fact empty.


Idle mode:


{

        "success": true,

        "result": {

               "sessions": []

         }

}


Ringing:


{

        "success": true,

        "result": {

              "sessions": [

                    {

                           "session": 45,

                           "direction": "outgoing",

                           "state": "ringing",

                           "calls": [

                               {

                                       "id": 89,

                                       "state": "ringing",

                                       "peer": "sip:MY_ID1@192.168.1.12"

                               }

                           ]

                    }

              ]

        }

}


Has anyone used the 2N API for this case or similar that can help out?


Best regards

+1

Hey!!! I think I got the solution.

2N now as an incredible webpage inside the unit, called "Automation".

I was able to fire up events from ringing and terminated, via RPC to bOS. Hohoooo!

Image 5143

If anyone needs something like this... here's the information.

I think you may need to have the HTTP API license. In my case the unit came with the full license.

I just had to create two different states, otherwise the boolean would stay as true. As soon as the call is terminated, the boolean is set to false. Now I'm going to play with it!

Best regards