# How to write the value of Opc Ua Node

**URL:** <https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863>\
**Category:** Module Development\
**Tags:** ignition80\
**Created:** [April 11, 2020, 1:06pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863 "2020-04-11T13:06:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![78503656](https://avatars.discourse-cdn.com/v4/letter/7/a9adbd/32.png) [@78503656](https://forum.inductiveautomation.com/u/78503656)\
**Post date:** [April 11, 2020, 1:06pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863/1 "2020-04-11T13:06:23Z")

</div>

I’m looking the OPC UA Device example.The example show how to add Opc Ua Node.  
But I have 2 question:  
1.how to update the value of Opc Ua Node, is ManagedAddressSpaceServices.write(WriteContext context,List writeValues) ?  
2.I try to update the value of one Opc Ua Node like this:  
node.writeAttribute(  
new AttributeContext(  
node.getNodeContext().getServer(),  
null  
),  
AttributeId.Value.uid(),  
new DataValue(new Variant((long) 101), StatusCode.GOOD),  
null  
);  
But the ig show err .“UaException: status=Bad\_TypeMismatch, message=The value supplied for the attribute is not of the same type as the attribute’s value.”

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 11, 2020, 1:13pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863/2 "2020-04-11T13:13:47Z")

</div>

You can call `node.setValue()` to update the value once, or install an `AttributeFilter` that will act as a callback any time an attribute is being read from the Node.

The device APIs are just a thin layer on top of the [Eclipse Milo OPC UA SDK](https://github.com/eclipse/milo). You may find it useful to look at examples that use the API [here](https://github.com/eclipse/milo/blob/master/milo-examples/server-examples/src/main/java/org/eclipse/milo/examples/server/ExampleNamespace.java) and [here](https://github.com/digitalpetri/opc-ua-demo-server).

---

<div class="post-metadata">

**Author:** ![78503656](https://avatars.discourse-cdn.com/v4/letter/7/a9adbd/32.png) [@78503656](https://forum.inductiveautomation.com/u/78503656)\
**Post date:** [April 12, 2020, 4:55am UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863/3 "2020-04-12T04:55:15Z")

</div>

hi Kevin.  
As you say,I try to install an `AttributeFilter` like:  
{  
node.setValue(new DataValue(new Variant(100 + i)));

```
            node.getFilterChain().addLast(
                new AttributeLoggingFilter(),
                AttributeFilters.getValue(
                    ctx ->
                        new DataValue(new Variant((long) new Random().nextInt()))
                )
            );
        }

```

but it run err :  
java.lang.NoSuchMethodError: ‘org.eclipse.milo.opcua.sdk.server.nodes.filters.AttributeFilterChain org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode.getFilterChain()’

in pom.xml,I have add:  
  
org.eclipse.milo  
sdk-server  
0.4.0

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 12, 2020, 12:07pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863/4 "2020-04-12T12:07:54Z")

</div>

Ah, I forgot `AttributeFilterchain` is new to version 0.4. The SDK currently uses a 0.3.x version of Milo. There is something called `AttributeDelegate` instead. Look at the examples from one of the 0.3 release branches: [https://github.com/eclipse/milo/blob/release/0.3.8/milo-examples/server-examples/src/main/java/org/eclipse/milo/examples/server/ExampleNamespace.java](https://github.com/eclipse/milo/blob/release/0.3.8/milo-examples/server-examples/src/main/java/org/eclipse/milo/examples/server/ExampleNamespace.java)

You shouldn’t add your own Milo dependency - you get one as a transitive dependency from the module SDK.

---

<div class="post-metadata">

**Author:** ![78503656](https://avatars.discourse-cdn.com/v4/letter/7/a9adbd/32.png) [@78503656](https://forum.inductiveautomation.com/u/78503656)\
**Post date:** [April 12, 2020, 1:24pm UTC](https://forum.inductiveautomation.com/t/how-to-write-the-value-of-opc-ua-node/33863/5 "2020-04-12T13:24:39Z")

</div>

I done it. Thanks for your support.
