Repository navigation
Getting started
Ralf Steinert edited this page Nov 2, 2026
·
1 revision
Python 3.10 or newer:
pip install opcua-sim
opcua-sim --versionopcua-sim 0.1.0
opcua-sim profiles # what is bundled
opcua-sim map drive # its variables, methods and alarms
opcua-sim serve --profile drive --name pumpopcua-sim: 1 device(s) on opc.tcp://127.0.0.1:4840, control on :4841
pump (drive)
Leave it running and use a second terminal.
opcua-sim has a small client built in. On the generic profiles pump.Speed is short for
ns=2;s=pump.Speed:
opcua-sim browse
opcua-sim write pump.SpeedSetpoint 30
opcua-sim call pump.Start
opcua-sim read pump.Speed pump.DeviceHealthopcua-sim inject pump trip code=4
opcua-sim read pump.State pump.FaultCode pump.DeviceHealth # 3, 4 and 1: tripped, failure
opcua-sim call pump.Start # refused: BadInvalidState
opcua-sim clear pump trip
opcua-sim call pump.Resetclear removes the cause, Reset clears the latch. In a second terminal, opcua-sim watch --alarms
prints the alarm events as they happen.
Look up the namespace index by its URI. The number is not fixed:
import asyncio
from asyncua import Client, ua
async def main(url="opc.tcp://127.0.0.1:4840"):
async with Client(url) as client:
idx = await client.get_namespace_index("urn:steitec:opcua-sim")
pump = client.get_node(ua.NodeId("pump.MethodSet", idx))
await pump.call_method(ua.NodeId("pump.Start", idx))
await asyncio.sleep(1)
speed = await client.get_node(ua.NodeId("pump.Speed", idx)).read_value()
print(f"{speed:.1f} Hz")
asyncio.run(main())name: demo plant
devices:
- {name: oven, profile: temperature-controller}
- {name: pump, profile: drive, params: {ramp: 5.0}}
- {name: tank_pressure, profile: pressure-transmitter, params: {process: 4.0}}
- {name: meter, profile: energy-meter, serial_number: EM-0042}opcua-sim serve --bench plant.yamlSecurity, users and your own profiles are in the README.
Next: Testing in CI or Fault injection recipes.
opcua-sim · MIT licensed · OPC UA is a trademark of the OPC Foundation. Siemens, Beckhoff, Phoenix Contact, CODESYS, Omron and Leuze are trademarks of their owners; opcua-sim is not affiliated with them.