Previous
Stop data capture
By default, the data management service syncs all captured data at a regular interval. Conditional sync lets you control when sync happens, so data accumulates locally until your conditions are met: sync only during off-peak hours, when connected to WiFi, after a sensor reading crosses a threshold, or based on any other logic you define.
Conditional sync uses a sensor component as a gate. You configure a sensor whose Readings() method returns "should_sync": true or "should_sync": false. At each sync interval, the data manager calls Readings() on this sensor before uploading. If the result is true, sync proceeds. If false, the cycle is skipped and data continues to accumulate locally.
The sensor is the only mechanism for conditional sync. There is no built-in rules engine or config-only option. Any logic you need goes in the sensor’s Readings() implementation. You can use an existing sensor module from the registry or write your own.
If selective_syncer_name is configured but the sensor cannot be found, scheduled sync is disabled until the sensor becomes available. Make sure the sensor is correctly configured and added to the data manager’s depends_on field.
This example uses the sync-at-time:timesyncsensor module to sync data only during a configured time window. You can substitute any sensor that returns should_sync.
On your machine’s CONFIGURE tab, click + next to your machine part and select Component or service.
Search for and select the sync-at-time:timesyncsensor model.
Click Add module, enter a name (for example, timesensor), and click Create.
Configure the time window in the sensor’s attributes:
{
"start": "18:00:00",
"end": "06:00:00",
"zone": "America/New_York"
}
| Field | Type | Required | Description |
|---|---|---|---|
start | string | Yes | Start of the sync window in HH:MM:SS format. |
end | string | Yes | End of the sync window in HH:MM:SS format. |
zone | string | Yes | Time zone (for example, "CET", "America/New_York"). |
Click Save.
The selective_syncer_name field is not available in the UI. Switch to JSON mode on the CONFIGURE tab.
Find the data management service in your config and add two fields:
selective_syncer_name: the name of your sync sensordepends_on: include the sensor name so the data manager waits for it to be available
{
"name": "data_manager-1",
"api": "rdk:service:data_manager",
"model": "rdk:builtin:builtin",
"attributes": {
"additional_sync_paths": [],
"selective_syncer_name": "timesensor",
"sync_interval_mins": 0.1,
"capture_dir": "",
"tags": []
},
"depends_on": ["timesensor"]
}
Click Save.
selective_syncer_name matches the sensor name exactly and that the sensor is in depends_on.If no existing module fits your use case, you can write a sensor module that implements whatever sync logic you need: check network connectivity, compare sensor readings to a threshold, query an external API, or combine multiple conditions.
The sensor must implement the sensor API and return a "should_sync" key with a boolean value from Readings(). The data manager checks this key at each sync interval. The sensor can return additional readings alongside should_sync.
The RDK provides a helper: datamanager.CreateShouldSyncReading(bool) returns a properly formatted readings map.
Readings() to return "should_sync": true when sync should proceed and "should_sync": false otherwise.Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!