Created
October 20, 2025 13:25
-
-
Save danielpeintner/b269e84f55093b6561c7cd6b268272ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Servient = require("@node-wot/core").Servient; | |
| OPCUAClientFactory = require("@node-wot/binding-opcua").OPCUAClientFactory; | |
| const thingDescription = { | |
| "@context": "https://www.w3.org/2019/wot/td/v1", | |
| "@type": ["Thing"], | |
| securityDefinitions: { nosec_sc: { scheme: "nosec" } }, | |
| security: "nosec_sc", | |
| title: "servient", | |
| properties: { | |
| pumpSpeed: { | |
| description: "the pump speed", | |
| type: "number", | |
| forms: [ | |
| { | |
| href: "opc.tcp://opcuademo.sterfive.com:26543?id=ns=1;s=PumpSpeed", // endpoint | |
| // "contentType": "application/octet-stream" // XXX UNCOMMENT and you will see what I mean | |
| }, | |
| ], | |
| } | |
| }, | |
| }; | |
| (async () => { | |
| const servient = new Servient(); | |
| servient.addClientFactory(new OPCUAClientFactory()); | |
| const wot = await servient.start(); | |
| const thing = await wot.consume(thingDescription); | |
| // pumpSpeed | |
| const contentPumpSpeed = await thing.readProperty("pumpSpeed"); | |
| const pumpSpeed = await contentPumpSpeed.value(); | |
| console.log("pumpSpeed is", pumpSpeed); | |
| await servient.shutdown(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment