Enable and disable Analytic Rule via camera Input Signal
AnsweredGood day
Is their a way we could enable and disable a rule via a camera Input signal or an I/O module?
My client is wanting his Intrusion push notifications to be active only when he arms his alarm. This seems to be getting requested more often. It would also be nice to be able to enable and disable rules via a soft trigger.
Any assistance would be greatly appreciated.
Thanks Keith Botha
-
Hi simon kent,
You can use the /ec2/saveEventRule to create or update an Event Rule.
Please refer to the details of the API via https://<server IP address>:7001/static/index.html#/developers/api/ec2/saveEventRule .
To complete the required information of the API, you may need to use the /ec2/getEventRules API.Here is what you can do to trigger this API by camera input signal, I/O module, or soft trigger:
1. Check the API explanation and construct the API, test it with the browser to make sure the API works.
2. Create the Event Rule and set the rule to be trigger by the Input Signal, or create a Soft Trigger rule depends on your desire.
3. In the Action column, select Do HTTP request in the Do dropdown menu.
4. In the HTTP URL, enter the /ec2/saveEventRule API you constructed.
5. In the HTTP Content, enter the body of the POST request of the API.
For further information, please refer to this support ARTICLE for how to constructing an Action to Do HTTP Request.Please kindly let me know if you have any further questions.
Thank you.0 -
Good day Anderson
Thank you very much for your prompt response. I will take a look at the article and give it a try. I might come back to you if I get stuck. Thanks again
0 -
Good day Anderson
I have had a look and to be honest, the API setup is a bit over my head. I understand how to setup the rule itself but the API setup is a bit tricky.
I need to be able to enable and disable a Analytic Event Rule that is already setup and working via this Rule.
your assistance is greatly appreciated.
Thanks Keith
0 -
Hi simon kent,
Here are the steps for setting up the Soft Trigger to enable/disable the existed Event Rule.
1. Get the Event Rule parameters for constructing the saveEventRule API
- Access https://<server IP>:<port>/ec2/getEventRules via the browser.
- Find and copy the parameters of the Event Rule you would like to control by the Soft Trigger. You will get something like:2. Create the Soft Trigger
- Create a Soft Trigger and set the parameters as you desired.
a. Select Do HTTP Request in Do drop-down menu.
b. Fill in the saveEventRule API in HTTP URL.
c. Paste the parameters you get in step 1 in HTTP content.
- Set the different rule statuses for enabling or disabling the rule.
- To enable the rule, set "disabled": false
- To disable the rule, set "disabled": true
d. Select Content type as application/json.
e. Enter the login credential.After setting up both enable and disable Soft Triggers, you should be able to change the status of the Event Rule on both desktop and mobile clients.
Thank you.
1 -
Good day Anderson
Ok so when I do step 1 I get a massive amount of information. I have tried to sort through what I want.
I have something like this: \"requestType\":\"\",\"streamQuality\":\"highest\",\"useSource\":true}","actionResourceIds":[],"actionType":"pushNotificationAction","aggregationPeriod":60,"comment":"","disabled":false,"eventCondition":"{\"analyticsEngineId\":\"{1e5613c4-b7ac-546d-6623-8c179de18114}\",\"eventTimestampUsec\":\"0\",\"eventType\":\"undefinedEvent\",\"inputPortId\":\"nx.hikvision.fielddetection\",\"metadata\":{\"allUsers\":false,\"level\":\"0\"},\"omitDbLogging\":false,\"reasonCode\":\"none\"}","eventResourceIds":["{1683cf74-10a2-3a37-2cb3-f8cbe527a968}"],"eventState":"Active","eventType":"analyticsSdkEvent","id":"{b68de46a-07ea-4c6a-833c-464e97d250af}","schedule":"","system":false},{"actionParams":"
Does that seem correct? I cant seem to work out where the Rule starts and ends. I am sorry to take up your time. Are we able to get Anydesk or Team Viewer support should I be unsuccessful?
Thanks again for the assistance
0 -
Hi simon kent,
You were doing the correct thing.
You did find one of the events but not the entire content.
Just need to find the correct head and the end of the event you would like to control.The getEventRules API returns the Event Rules information in JSON format by default.
For better reading the JSON format, you can follow one of the below options:
1. Install the JSON viewer extension on the browser
There are plenty of JSON viewer extensions on each browser, any one of them should work.
It will help to arrange the format on the page after getting the JSON format replies from the Nx server.2. Copy and paste the JSON format reply to the editor with the JSON format function
Many editors have built-in or plugins which can do the formatting for you, such as Notepad++, Atom, or Visual Studio Code.
Choose the editor you like, get the plugins if needed, then paste the JSON format reply from the Nx server to the editor, and let the editor do the formatting for you.You should be able to find the complete section of the Event Rule with a nice and neat JSON format composition, which is similar to the screenshot I provided in the previous comment.
If you are still getting trouble with the setting and require remote assistance, please let me know and I will convert this ticket into our ticket system for you to provide the sensitive information.Thank you.
0 -
Good day Anderson
Sorry for the delay in response. Thanks very much for the assistance. I will be working on it in the week. Will let you know how I go.
Thanks and enjoy the week ahead.
0 -
Good Day Anderson
Ok So I managed to get this with the JSON converter.
I Entered [https://192.168.1.21:7001/ec2/getEventRules] in the HTTP Request
Content Type: Application/JSON
Login: Would this be the NX login detail? I tried it with no luck
I changed to [ disabled true ] on the one soft Trigger and left it as false on the other
I did the rest as you requested. Does the Json script look correct?
I am keen to try a bit more on my own. Perhaps you can see something I might be missing
"actionParams":"{\"additionalResources\":[\"{00000000-0000-0000-0000-100000000000}\",\"{00000000-0000-0000-0000-100000000001}\"],\"allUsers\":false,\"authType\":\"authBasicAndDigest\",\"durationMs\":5000,\"forced\":true,\"fps\":10,\"needConfirmation\":false,\"playToClient\":true,\"recordAfter\":0,\"recordBeforeMs\":1000,\"requestType\":\"\",\"streamQuality\":\"highest\",\"useSource\":false}",
"actionResourceIds":[
"{da82cd35-3518-5fb1-061b-91ac81fa750d}"
],
"actionType":"bookmarkAction",
"aggregationPeriod":0,
"comment":"",
"disabled":false,
"eventCondition":"{\"analyticsEngineId\":\"{1e5613c4-b7ac-546d-6623-8c179de18114}\",\"eventTimestampUsec\":\"0\",\"eventType\":\"undefinedEvent\",\"inputPortId\":\"nx.hikvision.fielddetection\",\"metadata\":{\"allUsers\":false,\"level\":\"0\"},\"omitDbLogging\":false,\"reasonCode\":\"none\"}",
"eventResourceIds":[
"{da82cd35-3518-5fb1-061b-91ac81fa750d}"
],
"eventState":"Active",
"eventType":"analyticsSdkEvent",
"id":"{e6fb06c6-9331-479a-8f2e-5c932d1d89fb}",
"schedule":"",
"system":false0 -
I would like to join this conversation.......
Anderson,
This seems a very complicated way of starting/stopping a rule from the app
Perhaps a way to create schedules that start/stop from a soft trigger would be easier...
As our use of Analytics increases then we want more control over when they are active. I want all of my team, including customer service team, knowing how to add this to a site, not the just the tech boffins
Glenn
0 -
Good day Glenn
Thanks for joining in. I agree, we ideally need easy ways of enabling and disabling rules.
It would be great if there was an Event called 'Control Rule' and the Action would be how it needs to be controlled, Soft Trigger or Camera Input etc.
Anderson, If you could however for now take a look at how I have set it up and possibly point me in the right direction. Thanks again for all the assistance so far
Thanks Keith
0 -
Hi simon kent,
Yes, you got the correct section of one of the event rules. Just remember to complete the JSON format, the braces at the beginning and the end of the data, when you paste it to the Nx Event Rule.
Login: Would this be the NX login detail? I tried it with no luck
Yes, please fill in the Nx login credential.
I forgot to mention one thing, please select POST as Request Type if you find the rule does not work with Auto.
If you are still not able to get the rule to work, please share the screenshot of the Event Rule with me, I will help to check the setting.
Hi Glenn Grigor,
Since there are lots of different APIs across the different service providers or device manufacturers, the design concept of the HTTP Request is to provide the elasticity rule engine for the user to construct any rules to fit their needs.
We are open-mind to any suggestion, thank you for raising this idea with us.
1 -
Good day Anderson
I got it to work, thank you so much for all the assistance!!! Now that I understand it, its pretty straight forward.
Thanks and all the best!
0 -
Sorry Anderson
One last thing, If I use and I/O or Camera Input to control the HTTP request, would the rule be turned on with a input signal and off with the same input signal? Do I only create one rule? Or do I need two inputs, one for on and one for off? I have tested the Soft Trigger setup with two Soft Triggers, that works well.
Sorry to hassle you so much.
All the best
0 -
Hi simon kent,
No worries. : )
It's my job to answer your questions.One last thing, If I use and I/O or Camera Input to control the HTTP request, would the rule be turned on with a input signal and off with the same input signal? Do I only create one rule? Or do I need two inputs, one for on and one for off? I have tested the Soft Trigger setup with two Soft Triggers, that works well.
Good to hear that the Soft Triggers work.
Same as the Soft Trigger, you will need to define two input signals and create two rules for the I/O module as well. One for turn on and one for turn off.0 -
your answer is very helpfull, I was stuck ! Now works fine
0 -
Hi Julien ROMANO,
Thanks for letting us know about the status of your work.
I am glad that this discussion also helps the other user. : )
0
Please sign in to leave a comment.
Comments
16 comments