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 or API (see the How to create or modify Event Rule article).
Retrieve the all Event Rule from the system
First you need to know the ID of the rules that you want to enable or disable.
You can retrieve all current rules with the following API request:
https://<server_ip>:<server_port>/rest/v4/events/rules
| NOTE: If you add a comment to the Rule in Desktop Client Rules engine it easier to find the applicable rules |
The output would look like this, however a multitude of these objects.
[
{
"id": "f5bc47e7-7e07-2e12-24db-96bbcaa21511",
"event": {
"caption": {
"checkType": "inList",
"value": "61f2a1e9-3613-2a7b-3ab5-bf6605850de3"
},
"description": {
"checkType": "containsKeywords"
},
"omitLogging": false,
"source": {
"checkType": "containsKeywords"
},
"state": "instant",
"type": "generic"
},
"action": {
"acknowledge": false,
"intervalS": 0,
"type": "desktopNotification",
"users": {
"acceptAll": true,
"ids": [
"00000000-0000-0000-0000-100000000001",
"00000000-0000-0000-0000-100000000000"
]
}
},
"enabled": true,
"schedule": [],
"comment": "SUPPORT"
}
]
Create the Event Rules to Enable a Rule
- Create an Event Rule to enable Event Rule A. Set the desired Event trigger, for example, a Soft Trigger.
- In the Action column, open the Do dropdown menu and select Internal HTTP request.
- In the Endpoint field, enter
/rest/v4/events/rules/<ruleId> -
In the HTTP Content field, enter the body of the API PATCH request (the parameters from step 2), set the value of the “enabled” parameter to
true.
NOTE: Only add the relevant part!
For example:{
"enabled": true
} - Apply changes.
Create the Event Rules to Disable a Rule
To disable the rule, you repeat the previous steps to enable a Rule, except you change the enabledparameter value from trueto false.
For example:
{
"enabled": false
}
Comments
0 comments
Article is closed for comments.