Skip to main content

Tips & Best Practices for Exploration

This guide provides best practices for effective OPC UA address space exploration.

Start Small

Begin with a specific node rather than the entire server:

Good:

nodeId: "ns=2;s=Equipment.Reactor1"

Avoid:

nodeId: "i=85"  // Objects folder - very large!

Use Appropriate Output Type

Choose based on your needs:

// For monitoring: Use NodeId
outputType: "NodeId"

// For display: Use Value
outputType: "Value"

// For documentation: Use BrowsePath
outputType: "AliasedBrowsePath"

Cache Exploration Results

Structure rarely changes - cache the results:

// Function node: Cache structure
const cacheKey = 'reactor1_structure';
const cached = flow.get(cacheKey);

if (cached && (Date.now() - cached.timestamp < 3600000)) {
// Use cached (less than 1 hour old)
msg.payload = cached.structure;
return msg;
}

// Cache new result
flow.set(cacheKey, {
timestamp: Date.now(),
structure: msg.payload
});

return msg;

Validate Before Use

Always check the structure exists:

// Function node: Safe access
const structure = msg.payload;

if (!structure || Object.keys(structure).length === 0) {
node.error("Exploration returned no results");
return null;
}

return msg;

Common Use Cases

1. Generate Monitoring Configuration

Explore equipment and create monitoring setup:

// Explore with NodeId output
msg.outputType = "NodeId";
// Result goes to Monitor node

2. Documentation Generation

Create documentation of available data:

msg.outputType = "AliasedBrowsePath";
// Convert to markdown table

3. Dynamic Dashboard Creation

Build UI based on available data:

msg.outputType = "Value";
// Create dashboard widgets dynamically

4. Data Discovery

Find specific variables across the server:

// Function node: Find temperature variables
function findTemperatures(obj, path = '', result = []) {
for (const [key, value] of Object.entries(obj)) {
if (key.toLowerCase().includes('temp')) {
result.push({
name: key,
path: path ? `${path}.${key}` : key,
value: value
});
} else if (typeof value === 'object') {
findTemperatures(value, path ? `${path}.${key}` : key, result);
}
}
return result;
}

const temps = findTemperatures(msg.payload);
msg.payload = temps;
return msg;

Next Steps

See Also