Is the Nx Cloud up? Visit our Status Page for the current health and performance of the Nx Cloud.

Status Page

How to subscribe to Nx motion events on a camera

Answered

Comments

11 comments

  • Official comment
    Norman
    • Network Optix team

    Hi @...,

    Can you describe the steps a bit more about what you want to achieve? 

    To enable or disable a rule, the saveEventRule part of our server API should enable you to create such thing. 

    Some more information can be found in THIS support article. 

     

  • Permanently deleted user

    Hi Norman,

    I want to achieve the following 

    1. A program to listen motion events from a camera

    2. Once motion is detected, the program can get notified and it can trigger a recording and do its own logic 

    In a nutshell, I want to listen motion events from Nx camera and do my own logic when a motion is detected

    Regards

    Sebastian

    0
  • Norman
    • Network Optix team

    Hi @....

    I would set up a rule as follows: 

    Event = Motion Detection ⇾ Action = Send HTTP event

    When your program receives the HTTP event, and your logic has been meet, follow the suggestions in the support article I linked to in my previous response. 

    Also, please check the following support articles which might be useful for your use case: 

    1
  • Permanently deleted user

    Thanks 

    0
  • Permanently deleted user

    Hi Norman

    How can I pass the camera Id to the http endpoint from the event rule ?

    Do you have any samples for that

    0
  • Norman
    • Network Optix team

    Hi @...,

    The best practice would be to create two rules in this case. 

    1. Event = Motion Detection ⇾ Action = Send HTTP event (1)

    2. Event = Generic Event -> Action = Send HTTP event (2)

    The first HTTP event that is sent, is sent (and received) to the Nx Media Server itself. The second HTTP event is sent to your application. 

    Example URL, please check the server API for the createEvent section for more information: 

    http://<serverIp>:<port>/api/createEvent?source=<uniqueSource>caption=<uniqueCaption>&metadata={"cameraRefs":["cameraId"]}
    

     

    0
  • Permanently deleted user

    Hi Norman,

    Thanks for the reply. I still didn't understand how my custom HTTP end point receives camera id dynamically

    Do Nx have some token which will be replaced at runtime ?

    for example

    http://localhost/my-event?cameraId={cameraId}&eventname=XXXX&....

    This endpoint I want to configure as the target action of the motion event rule

    or else I configure different rules for each camera and hardcode the cameraId ?

    0
  • Andrey Terentyev
    • Network Optix team


    Hello Sebastian,

    > I still didn't understand how my custom HTTP end point receives camera id dynamically
    > Do Nx have some token which will be replaced at runtime ?
    Yes, it does.

     

    The approach is:

    1. For each camera you create a rule for detecting a motion on the camera.

    The action should be "Do HTTP Request" triggering Generic Event.

    For example,

    http://<serverIp>:<port>/api/createEvent?source=cameraId&caption=motion

    cameraId - is the ID of the camera
    caption or description parameter can be used for storing a sting-tad distinguishing generic event type.

    Of course, you can create this bunch of rules over API with /ec2/saveEventRule


    2. You create one Generic Event rule.
    The action should be "Do HTTP request" to the URL of your system

    http://localhost/my-event?cameraId={event.source}&eventname={event.caption}&someparam={event.description}

    {event.source} - would be automatically replaced by the Generic Event's source field value
    {event.caption} - would be automatically replaced by the Generic Event's caption field value
    {event.description} - would be automatically replaced by the Generic Event's description field value

    Please, have a look at these threads for details.
    https://support.networkoptix.com/hc/en-us/community/posts/360042988034-How-to-use-execHttpRequestAction-and-it-complete-functionality
    https://support.networkoptix.com/hc/en-us/community/posts/360043672414--api-executeEventAction

    0
  • Permanently deleted user

    Hi Norman,

    Thanks for the explanation. 

    Now my question is if I bind "Do HTTP Action" with following url directly to a motion event  instead of generic event, will it work ?

    http://localhost/my-event?cameraId={event.source}

    0
  • Andrey Terentyev
    • Network Optix team

    Hello,

    It won't.

    But if you have a lot of cameras you could automate creation of motion detection rules by a script.

    1. You invoke gatCemerasEx for getting the list of cameras.

    2. You iterate through the list of cameras and create a motion detection rule per camera with /ec2/saveEventRule

    Since you have all the info about a camera (cameraId, model etc.), you could create a rule having exact URL in the "Do HTTP Request" action. For example,

    http://localhost/my-event?cameraId=<cameraId taken from the list>&eventname=<your tag for motion detection>&someparam=<another specific parameter value>

     

    0
  • Permanently deleted user

    Hi Andrey,

    Thanks for the clarification. It is clear now

    0

Please sign in to leave a comment.