Sometimes users want to enable or disable an Analytic Event Rule via a camera input signal, I/O module, or soft trigger. For example, users may want to have an Analytics Event Rule be active only when an alarm is armed, soft trigger is pressed, or input from a camera is received. This can be accomplished through an API request.
Create an Analytics Event Rule
If you already have the desired Analytics Event Rule set up, skip ahead to the next section. Otherwise, create an Analytics Event Rule via the Rules Engine (see the User Event: Analytic Event article for more details) or API (see the How to create or modify Event Rule article).
Create Event Rules to Enable/Disable the Analytics Event
- Visit https://<server_ip>:<server_port>/ec2/getEventRules in the browser.
- Find and copy the parameters of the Event Rule you would like to control.
Example:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"eventType": "undefinedEvent",
"eventResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"eventCondition": "string",
"eventState": "inactive",
"actionType": "undefinedAction",
"actionResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"actionParams": "string",
"aggregationPeriod": 0,
"disabled": false,
"comment": "string",
"schedule": "string",
"system": true
} - Create an Event Rule to enable Event Rule A. Set it to be triggered via Soft Trigger, Input Signal on Camera, or I/O module.
- In the Action column, open the Do dropdown menu and select Do HTTP request.
- In the HTTP URL field, enter https://<server_ip>:<port>/ec2/saveEventRule
- In the HTTP Content field, enter the body of the API POST request (the parameters from step 2). Change the value of the “disabled” parameter to false.
Example:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"eventType": "undefinedEvent",
"eventResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"eventCondition": "string",
"eventState": "inactive",
"actionType": "undefinedAction",
"actionResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"actionParams": "string",
"aggregationPeriod": 0,
"disabled": false,
"comment": "string",
"schedule": "string",
"system": true
} - Open the Content type dropdown and select application/json.
- Open the Request type dropdown and select POST.
- Enter the login and password.
- Apply changes.
- Create an Event Rule to disable Event Rule A. Set it to be triggered via Soft Trigger, Input Signal on Camera, or I/O module.
- Repeat steps 4-6. Change the value of the “disabled” parameter in the HTTP Content field to true.
Example:
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"eventType": "undefinedEvent",
"eventResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"eventCondition": "string",
"eventState": "inactive",
"actionType": "undefinedAction",
"actionResourceIds": [
"3fa85f64-5717-4562-b3fc-2c963f66afa6"
],
"actionParams": "string",
"aggregationPeriod": 0,
"disabled": true,
"comment": "string",
"schedule": "string",
"system": true
} - Repeat steps 7-9.
- Apply changes.
For more information, please refer to the Do HTTP Request and How to start/stop recording using Nx Witness Generic Event articles.
Questions
If you have any questions related to this topic, or you want to share your experience with other community members or our team, please visit and engage in our support community or reach out to your local reseller.
Comments
0 comments
Article is closed for comments.