Skip to main content

DataChangeFilter

Overview​

OPC UA Part 4 §7.17 DataChangeFilter lets the client tell the server when to push data, thereby reducing publish traffic:

  • Trigger — Trigger Conditions (Status / StatusValue / StatusValueTimestamp)
  • DeadbandType — Deadband Type (None / Absolute / Percent)
  • DeadbandValue — Deadband Value
In the current version, the filter does not actually take effect

DataChangeFilter on classes and fields that exist; it accepts them anyway sub.add_node(..., filter=...), but SDK It won't be sent to the server.. Passing a filter does not trigger an error or reduce traffic; data is still reported in full according to the server's default rules. The field descriptions below are for the "definition layer"; please use them as a guide and do not treat them as actual filtering behavior that has taken effect.

API​

Class / FieldCategoryReading and WritingNote
DataChangeFilter(trigger, deadband_type, deadband_value)Class—Filter
sub.add_node(node_id, callback, attribute, sampling_interval_ms, mode, queue_size, discard_oldest, filter)MethodsWriteAccept the full signature of the filter

Related Structures:

class DataChangeTrigger(IntEnum):
STATUS = 0 # Changes StatusCode Only
STATUS_VALUE = 1 # StatusCode or Value change (default)
STATUS_VALUE_TIMESTAMP = 2 # Any change

class DeadbandType(IntEnum):
None_ = 0 # No dead zone
Absolute = 1 # Absolute Dead Zone
Percent = 2 # Percentage Dead Zone (Based on EURange)

DataChangeFilter It is an immutable structure with three fields whose default values are: trigger=DataChangeTrigger.STATUS_VALUE,deadband_type=DeadbandType.None_, deadband_value=0.0.

Code Example​

from darra_opcua import (
DarraOpcUa, AttributeId, MonitoringMode,
DataChangeFilter, DataChangeTrigger, DeadbandType
)

with DarraOpcUa("opc.tcp://localhost:4840") as ua:
ua.connect()

sub = ua.create_subscription(publishing_interval_ms=100)

# 1) Absolute Dead Zone 0.5
filter1 = DataChangeFilter(
trigger=DataChangeTrigger.STATUS_VALUE,
deadband_type=DeadbandType.Absolute,
deadband_value=0.5,
)
mi1 = sub.add_node("ns=2;s=Temp", attribute=AttributeId.Value,
sampling_interval_ms=100,
mode=MonitoringMode.Reporting, queue_size=1,
discard_oldest=True, filter=filter1)

# 2) Percentage deadband: 2%
filter2 = DataChangeFilter(deadband_type=DeadbandType.Percent, deadband_value=2.0)
mi2 = sub.add_node("ns=2;s=Flow", attribute=AttributeId.Value,
sampling_interval_ms=100, filter=filter2)

# 3) Status changes only
filter3 = DataChangeFilter(trigger=DataChangeTrigger.STATUS)
mi3 = sub.add_node("ns=2;s=CommStatus", attribute=AttributeId.Value,
sampling_interval_ms=200, filter=filter3)

def on_dc(args):
print(f"[mi={args.monitored_item_handle}] {args.value_string} ({args.status.name})")

sub.data_changed.append(on_dc)

Conduct and Restrictions​

  • The current version does not support passing down filters; regardless of whether the server supports filtering, it is treated as if it does not, and filters never take effect.
  • MI Create as usual; report all data.
  • The filter is passed only when the object is created; Subscriptions will not be reinstated after the system is restored.。
  • If it doesn't take effect, send a push notification OpcUaEventCategory.Diagnostic / OpcUaEventSeverity.Warn event with the message: "This DataChangeFilter feature is not available in the current version."
  • Percent Dead Zone is, by definition, based on a percentage of the target node's EURange.

Best Practices​

  • For analog values, use "Absolute" as the default, such as 0.5°C
  • Use "Percent" for wide-range signals
  • Digital signals do not require filtering
  • Before the filter takes effect, please perform your own numerical checks in the callback to reduce traffic.

Cross-Language Comparison​

C#PythonJavaC++RustC
DataChangeFilterDataChangeFilterDataChangeFilterDataChangeFilterDataChangeFilterDarraUa_DataChangeFilter

The names of the enumeration members differ on both sides; they must be rewritten when porting between languages:

EnumerationC#Python
DeadbandTypeNone / Absolute / PercentNone_ / Absolute / Percent
DataChangeTriggerStatus / StatusValue / StatusValueTimestampSTATUS / STATUS_VALUE / STATUS_VALUE_TIMESTAMP

Next Step​