DataHub

Adapter Contract

JSON telemetry event schema and NATS subject conventions.

All adapters — in-process drivers or external processes in any language — publish telemetry using this contract.

When to use which adapter

ApproachExamplesNotes
In-process (orchestrator)SIMULATOR, MQTT, SIEMENS_S7, OPC_UAConfigured on the device in the console; orchestrator manages lifecycle
External processMELSEC_A1E, BECKHOFF_ADS, customPublish to NATS from iot/ or your own service using this schema
Not implementedMODBUS_TCPDevice may show NOT_IMPLEMENTED until a driver ships

See Plants, machines, and devices for console setup.

NATS subject

datahub.telemetry.<plantCode>.<deviceCode>

Example: datahub.telemetry.gebze.s7-1500-01

JetStream persists events for history; Redis holds latest values for the UNS.

Event payload

{
  "eventId": "550e8400-e29b-41d4-a716-446655440000",
  "tagPath": "gebze/press-line-01/s7-1500-01/motor.current",
  "plantCode": "gebze",
  "machineCode": "press-line-01",
  "deviceCode": "s7-1500-01",
  "tagCode": "motor.current",
  "value": 12.7,
  "valueType": "DOUBLE",
  "unit": "A",
  "quality": "GOOD",
  "source": "SIMULATOR",
  "sourceTimestamp": "2026-07-21T12:00:00.000Z",
  "metadata": {}
}

Field definitions

FieldTypeRequiredDescription
eventIdUUID stringYesUnique per event; enables idempotent delivery
tagPathstringYesFull hierarchy path
plantCodestringYesPlant code
machineCodestringYesMachine code
deviceCodestringYesDevice code
tagCodestringYesTag code
valueanyYesTag value (number, string, boolean)
valueTypestringYesDOUBLE, INT, BOOL, STRING, etc.
unitstringNoEngineering unit (A, °C, bar, etc.)
qualitystringYesGOOD, BAD, UNCERTAIN, TIMEOUT, DISCONNECTED, CONFIG_ERROR
sourcestringYesAdapter identifier (SIMULATOR, MQTT, SIEMENS_S7, etc.)
sourceTimestampISO 8601YesTimestamp from the source device
metadataobjectNoAdapter-specific metadata

Control subjects

SubjectPurpose
datahub.rule.changedRule-worker reloads rule cache
datahub.device.changedOrchestrator reconciles adapters

External adapter (Python)

The repository includes Python templates under iot/ that connect to field devices and publish to NATS:

  1. Configure NATS URL to reach the stack (nats://… from your network)
  2. Map reads to tagPath, value, quality, and sourceTimestamp
  3. Publish JSON payloads to datahub.telemetry.<plant>.<device> per tag batching policy

Use the same eventId UUID per event for idempotent ingestion.

Programs and rules consume telemetry after it lands in NATS — external adapters do not need API credentials if NATS is reachable on your deployment network.