Skip to content

Instantly share code, notes, and snippets.

@danielpeintner
Created October 20, 2025 13:25
Show Gist options
  • Select an option

  • Save danielpeintner/b269e84f55093b6561c7cd6b268272ea to your computer and use it in GitHub Desktop.

Select an option

Save danielpeintner/b269e84f55093b6561c7cd6b268272ea to your computer and use it in GitHub Desktop.
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