OPC UA CreateMonitoredItems: Resolving Null Id Values

Jason IP1 min read
OPC / OPC UAOther ManufacturerTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

An OPC UA event subscription can return EnabledState correctly while returning Null for EnabledState/Id. The select clause is the cause: Id is a nested event field, so the filter must represent its browse path as an array of QualifiedName elements.

Identify the failing select clause

The monitored item targets ObjectIds.Server in MonitoringMode.Reporting. The event notification contains EnabledState = Enabled, but EnabledState/Id = Null, even though UaExpert displays the nested value.

The failing configuration converts the nested path into one string:

monitoredItem.Filter.SelectClauses.Add(
    AbsoluteName.ToString(BrowseNames.EnabledState, BrowseNames.Id));

Represent the nested browse path correctly

When an event field node is not referenced directly by the event type, pass each browse-path element separately in a QualifiedName[]. Replace the string-based clause with:

monitoredItem.Filter.SelectClauses.Add(
    ObjectTypeIds.ConditionType,
    new QualifiedName[] {
        BrowseNames.EnabledState,
        BrowseNames.Id
    });
Field request Representation Observed result
EnabledState Direct browse name Value returned
EnabledState/Id Single string from AbsoluteName.ToString Null
EnabledState/Id Two-element QualifiedName[] Correct nested-path configuration

Apply and verify the correction

  1. Remove the AbsoluteName.ToString(BrowseNames.EnabledState, BrowseNames.Id) select clause.
  2. Add the clause using ObjectTypeIds.ConditionType and the ordered path elements BrowseNames.EnabledState followed by BrowseNames.Id.
  3. Create the monitored items again and generate an alarm event that changes state.
  4. Inspect the corresponding field in NewEvent.Event. Confirm that EnabledState/Id no longer appears as Null and agrees with the value visible in UaExpert.

Use the same path construction for the other nested state identifiers already requested by the filter: AckedState/Id and ActiveState/Id. Preserve the parent-to-child order in each QualifiedName[].

FAQ

Why is OPC UA EnabledState returned but EnabledState/Id is Null?

EnabledState is selected directly, while Id is nested beneath it. Represent the nested field with a two-element QualifiedName[] instead of one path string.

What select clause retrieves ConditionType EnabledState Id?

Use ObjectTypeIds.ConditionType with new QualifiedName[] { BrowseNames.EnabledState, BrowseNames.Id }.

How should AckedState/Id and ActiveState/Id be selected?

Apply the same parent-to-child array pattern: pair BrowseNames.AckedState or BrowseNames.ActiveState with BrowseNames.Id in a QualifiedName[].

Back to blog