Skip to main content

Initializers

The initializers section sets initial values for variable nodes. These values are embedded in the generated NodeSet2.xml and loaded by the OPC UA server on startup.

Initializers can be placed either inside an instance (scoped to that instance) or at the top level of the model (using full paths).


Setting initial values

Setting initial values
instances:
- browseName: Sensor1
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Temperature
value: 22.5
- variable: Pressure
value: 1013.25

Accessing properties of an AnalogItemType variable

Use . to reach the properties (e.g. EURange, EngineeringUnits) of a variable node:

AnalogItemType property path
instances:
- browseName: Sensor2
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Level
value: 75.0
- variable: Level.ua:EngineeringUnits
value: "%"

Engineering units shorthand

For AnalogItemType-based variables, engineeringUnits accepts a plain unit string — no need to write out the full UNECE record:

Engineering units shorthand
instances:
- browseName: Sensor3
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Level
value: 42.0
engineeringUnits: "%"
- variable: Temperature
value: 23.5
engineeringUnits: "°C"

Initializing an optional member

Giving a variable a value implies that the variable is there. When variable: targets a member whose modelling rule is Optional, it is opted in automatically — the instance does not need to repeat it under optionals::

An Optional member needs no optionals: entry
instances:
- browseName: Sensor4
typeDefinition: SensorType
organizedBy: /ua:Objects
# no `optionals:` needed — the initializer below opts SerialNumber in
initializers:
- variable: SerialNumber
value: SN-00417

Every Optional node along the path is materialised, not just the last one, so Bay/Occupancy works when Bay is optional too. Listing the member under optionals: anyway is redundant rather than an error.

The same holds for propertyValues: — a value written at any depth of that tree opts its path in.

note

A member the type does not declare at all is still an error. Auto-activation applies to optional members, and never invents one from a misspelling.


Top-level initializers (full path syntax)

Top-level initializers: uses the full InstanceName/VariableName path. Useful for keeping instance declarations and initial values in clearly separate sections:

Top-level initializers
initializers:
# the instance name roots the path, with or without the `$` sigil
- variable: Sensor1/Temperature
value: 18.0
- variable: $Sensor1/Pressure
value: 1005.0
# and the same "initializing implies presence" rule applies from up here:
# Sensor2 declares no `optionals:` either
- variable: $Sensor2/SerialNumber
value: SN-00218

The first segment names the instance and may be written with or without the $ sigil — $Sensor1/Temperature and Sensor1/Temperature resolve identically. See Browse paths and anchors.

A top-level entry means exactly what the same entry written inside the instance means, including the optional-member rule above.


Duplicate path detection

The LSP server detects duplicate variable: paths within the same initializers: block and reports a DSL-E error. Each variable path must appear at most once.


📄 Full working example — initializers.model.yaml
# yaml-language-server: $schema=../../../../schemas/nodeset2.schema.json
#
# Living documentation example for: s66_initializers.md
# Validate: opcua-modeler generate --input initializers.model.yaml
#
namespaceUri: http://example.com/doc-examples/initializers/
namespaces:
- di
version: 1.0.0

objectTypes:
- browseName: SensorType
components:
- browseName: Temperature
dataType: ua:Double
- browseName: Pressure
dataType: ua:Double
- browseName: Level
dataType: ua:Double
typeDefinition: ua:AnalogUnitRangeType
- browseName: SerialNumber
dataType: ua:String
modellingRule: Optional

instances:
- browseName: Sensor1
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Temperature
value: 22.5
- variable: Pressure
value: 1013.25

- browseName: Sensor2
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Level
value: 75.0
- variable: Level.ua:EngineeringUnits
value: "%"

- browseName: Sensor3
typeDefinition: SensorType
organizedBy: /ua:Objects
initializers:
- variable: Level
value: 42.0
engineeringUnits: "%"
- variable: Temperature
value: 23.5
engineeringUnits: "°C"

- browseName: Sensor4
typeDefinition: SensorType
organizedBy: /ua:Objects
# no `optionals:` needed — the initializer below opts SerialNumber in
initializers:
- variable: SerialNumber
value: SN-00417

initializers:
# the instance name roots the path, with or without the `$` sigil
- variable: Sensor1/Temperature
value: 18.0
- variable: $Sensor1/Pressure
value: 1005.0
# and the same "initializing implies presence" rule applies from up here:
# Sensor2 declares no `optionals:` either
- variable: $Sensor2/SerialNumber
value: SN-00218
📄 Generated NodeSet2.xml — initializers.model.Nodeset2.xml
initializers.model.Nodeset2.xml
<?xml version="1.0"?>
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:ns1="http://example.com/doc-examples/initializers/Type.xsd">
<NamespaceUris>
<Uri>http://example.com/doc-examples/initializers/</Uri>
</NamespaceUris>
<Models>
<Model ModelUri="http://example.com/doc-examples/initializers/" Version="1.0.0" PublicationDate="2026-07-31T16:29:00.000Z">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.05.06" PublicationDate="2025-11-08T00:00:00.000Z"/>
</Model>
</Models>
<Aliases>
<Alias Alias="Double">i=11</Alias>
<Alias Alias="EUInformation">i=887</Alias>
<Alias Alias="HasComponent">i=47</Alias>
<Alias Alias="HasModellingRule">i=37</Alias>
<Alias Alias="HasProperty">i=46</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
<Alias Alias="Organizes">i=35</Alias>
<Alias Alias="Range">i=884</Alias>
<Alias Alias="String">i=12</Alias>
</Aliases>
<!--ReferenceTypes-->
<!--ObjectTypes-->
<!--ObjectType - 1:SensorType {{{{ -->
<UAObjectType NodeId="ns=1;i=1000" BrowseName="1:SensorType">
<DisplayName>SensorType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1001</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1002</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1003</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1021</Reference>
</References>
</UAObjectType>
<UAVariable NodeId="ns=1;i=1001" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1002" BrowseName="1:Pressure" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="Double">
<DisplayName>Pressure</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1003" BrowseName="1:Level" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="Double">
<DisplayName>Level</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=17570</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1004</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1020</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1004" BrowseName="EURange" ParentNodeId="ns=1;i=1003" AccessLevel="3" DataType="Range">
<DisplayName>EURange</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=885</Identifier>
</TypeId>
<Body>
<Range>
<Low>-1</Low>
<High>1</High>
</Range>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1020" BrowseName="EngineeringUnits" ParentNodeId="ns=1;i=1003" DataType="EUInformation">
<DisplayName>EngineeringUnits</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1021" BrowseName="1:SerialNumber" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="String">
<DisplayName>SerialNumber</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasModellingRule">i=80</Reference>
</References>
</UAVariable>
<!--ObjectType - 1:SensorType }}}}-->
<!--VariableTypes-->
<!--Other Nodes-->
<!--Object - 1:Sensor1 {{{{ -->
<UAObject NodeId="ns=1;i=1005" BrowseName="1:Sensor1">
<DisplayName>Sensor1</DisplayName>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1006</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1007</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1008</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;i=1006" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1005" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:Double>18</uax:Double>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1007" BrowseName="1:Pressure" ParentNodeId="ns=1;i=1005" AccessLevel="3" DataType="Double">
<DisplayName>Pressure</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:Double>1005</uax:Double>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1008" BrowseName="1:Level" ParentNodeId="ns=1;i=1005" AccessLevel="3" DataType="Double">
<DisplayName>Level</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=17570</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1009</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1022</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1009" BrowseName="EURange" ParentNodeId="ns=1;i=1008" AccessLevel="3" DataType="Range">
<DisplayName>EURange</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=885</Identifier>
</TypeId>
<Body>
<Range>
<Low>-1</Low>
<High>1</High>
</Range>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1022" BrowseName="EngineeringUnits" ParentNodeId="ns=1;i=1008" DataType="EUInformation">
<DisplayName>EngineeringUnits</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<!--Object - 1:Sensor1 }}}} -->
<!--Object - 1:Sensor2 {{{{ -->
<UAObject NodeId="ns=1;i=1010" BrowseName="1:Sensor2">
<DisplayName>Sensor2</DisplayName>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1011</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1012</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1013</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1024</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;i=1011" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1010" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1012" BrowseName="1:Pressure" ParentNodeId="ns=1;i=1010" AccessLevel="3" DataType="Double">
<DisplayName>Pressure</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1013" BrowseName="1:Level" ParentNodeId="ns=1;i=1010" AccessLevel="3" DataType="Double">
<DisplayName>Level</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=17570</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1014</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1023</Reference>
</References>
<Value>
<uax:Double>75</uax:Double>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1014" BrowseName="EURange" ParentNodeId="ns=1;i=1013" AccessLevel="3" DataType="Range">
<DisplayName>EURange</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=885</Identifier>
</TypeId>
<Body>
<Range>
<Low>-1</Low>
<High>1</High>
</Range>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1023" BrowseName="EngineeringUnits" ParentNodeId="ns=1;i=1013" DataType="EUInformation">
<DisplayName>EngineeringUnits</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=888</Identifier>
</TypeId>
<Body>
<EUInformation>
<NamespaceUri>http://www.opcfoundation.org/UA/units/un/cefact</NamespaceUri>
<UnitId>20529</UnitId>
<DisplayName>
<Text>% or pct</Text>
</DisplayName>
<Description>
<Text>percent - A unit of proportion equal to 0.01. (1 x 10⁻²)</Text>
</Description>
</EUInformation>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1024" BrowseName="1:SerialNumber" ParentNodeId="ns=1;i=1010" AccessLevel="3" DataType="String">
<DisplayName>SerialNumber</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:String>SN-00218</uax:String>
</Value>
</UAVariable>
<!--Object - 1:Sensor2 }}}} -->
<!--Object - 1:Sensor3 {{{{ -->
<UAObject NodeId="ns=1;i=1015" BrowseName="1:Sensor3">
<DisplayName>Sensor3</DisplayName>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1016</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1017</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1018</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;i=1016" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1015" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:Double>23.5</uax:Double>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1017" BrowseName="1:Pressure" ParentNodeId="ns=1;i=1015" AccessLevel="3" DataType="Double">
<DisplayName>Pressure</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1018" BrowseName="1:Level" ParentNodeId="ns=1;i=1015" AccessLevel="3" DataType="Double">
<DisplayName>Level</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=17570</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1019</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1025</Reference>
</References>
<Value>
<uax:Double>42</uax:Double>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1019" BrowseName="EURange" ParentNodeId="ns=1;i=1018" AccessLevel="3" DataType="Range">
<DisplayName>EURange</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=885</Identifier>
</TypeId>
<Body>
<Range>
<Low>-1</Low>
<High>1</High>
</Range>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1025" BrowseName="EngineeringUnits" ParentNodeId="ns=1;i=1018" DataType="EUInformation">
<DisplayName>EngineeringUnits</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<!--Object - 1:Sensor3 }}}} -->
<!--Object - 1:Sensor4 {{{{ -->
<UAObject NodeId="ns=1;i=1026" BrowseName="1:Sensor4">
<DisplayName>Sensor4</DisplayName>
<References>
<Reference ReferenceType="Organizes" IsForward="false">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=1;i=1000</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1027</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1028</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1029</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1032</Reference>
</References>
</UAObject>
<UAVariable NodeId="ns=1;i=1027" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1026" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1028" BrowseName="1:Pressure" ParentNodeId="ns=1;i=1026" AccessLevel="3" DataType="Double">
<DisplayName>Pressure</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1029" BrowseName="1:Level" ParentNodeId="ns=1;i=1026" AccessLevel="3" DataType="Double">
<DisplayName>Level</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=17570</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1030</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1031</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1030" BrowseName="EngineeringUnits" ParentNodeId="ns=1;i=1029" DataType="EUInformation">
<DisplayName>EngineeringUnits</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1031" BrowseName="EURange" ParentNodeId="ns=1;i=1029" AccessLevel="3" DataType="Range">
<DisplayName>EURange</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>i=885</Identifier>
</TypeId>
<Body>
<Range>
<Low>-1</Low>
<High>1</High>
</Range>
</Body>
</ExtensionObject>
</Value>
</UAVariable>
<UAVariable NodeId="ns=1;i=1032" BrowseName="1:SerialNumber" ParentNodeId="ns=1;i=1026" AccessLevel="3" DataType="String">
<DisplayName>SerialNumber</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:String>SN-00417</uax:String>
</Value>
</UAVariable>
<!--Object - 1:Sensor4 }}}} -->
</UANodeSet>