This guide explains how to use Soft Triggers and Internal HTTPS requests within the Rules engine to control recording for single or multiple devices.
Prerequisites
A recording schedule must already be configured for the target devices.
Administrative access to the System Administration/Rules menu.
The Camera ID for each device (found in Camera Settings > General or via the API).
Option 1: Controlling a Single Device
This method uses a direct API call to a specific camera to toggle its recording schedule.
Rule 1: Start Recording
Event: Soft Trigger (Name it "Start Recording")
Action: Internal HTTPS request
Endpoint:
/rest/v4/devices/<cameraId>Method: PATCH
Content:
{ "schedule": { "isEnabled": true } }Interval of Action: Instant
Rule 2: Stop Recording
Event: Soft Trigger (Name it "Stop Recording")
Action: Internal HTTPS request
Endpoint:
/rest/v4/devices/<cameraId>Method: PATCH
Content:
{ "schedule": { "isEnabled": false } }Interval of Action: Instant
Option 2: Controlling Multiple Devices
If you need to start/stop recording on several cameras simultaneously with one click, use a Generic Event as a middleman.
Step A: Create the Main Trigger
Create a Rule where the Soft Trigger sends a Generic Event to the system.
Event: Soft Trigger
Action: Internal HTTPS request
Endpoint:
/rest/v4/events/genericMethod: POST
Content:
{"source": "StartRecording"}
Step B: Create Device-Specific Rules
For each device you want to include in the group, create a rule that listens for that Generic Event:
Event: Generic Event (Source contains:
StartRecording)Action: Internal HTTPS request
Endpoint:
/rest/v4/devices/<cameraId>Method: PATCH
Content:
{"schedule": {"isEnabled": true}}
To stop the group, simply repeat Step A and B using the keyword {"source": "StopRecording"}and Content {"schedule": {"isEnabled": false}}
Option 3: Scaling for Large Systems
When managing hundreds of devices, creating individual rules is inefficient. Instead, use a centralized script to batch-process the commands.
NOTE: Use unique script names for each action, such as StartRecording.sh and StopRecording.sh. These can be written in Bash, Batch, or Python to efficiently manage bulk commands. |
1. The Scripting Logic
Develop a script to handle the heavy lifting:
Looping: Iterates through a predefined list of Camera IDs.
Execution: Sends the
PATCH /rest/v4/devices/<cameraId>request to each device to toggle recording following the methodology as shared above.
2. Triggering the Scripts
Instead of one rule per camera, you only need two rules (one for Start, one for Stop) to execute your scripts via another API request.
Rule 1: Start Recording
Event: Soft Trigger (Name it "Start Recording")
Action: Internal HTTPS request
Endpoint:
/rest/v4/servers/{serverId}/scripts/{scriptName}/runMethod: POST
Content:
{ "args": [ "" ], "waitForFinished": true }Interval of Action: Instant
Rule 2: Stop Recording
Event: Soft Trigger (Name it "Stop Recording")
Action: Internal HTTPS request
Endpoint:
/rest/v4/servers/{serverId}/scripts/{scriptName}/runMethod: POST
Content:
{ "args": [ "" ], "waitForFinished": true }Interval of Action: Instant
Alternative Events
While this guide focuses on Soft Triggers and Generic Events, you can substitute the initial "Event" with Input Signal on Camera. This requires at least 2 inputs: for example Input 1 to start and Input 2 to stop.
Instead of the inputs on cameras, this inputs could also be used from a support I/O device.
Comments
0 comments
Article is closed for comments.