Feature

AI-Assisted Twin Generation

Use your own AI agent with SPX MCP to turn requirements into editable models. Review the YAML, run a virtual device and verify the response through your protocol.

Describe the device. Keep control of the model.

Use your own AI agent with SPX MCP to turn requirements, protocol notes or device documentation into a reviewable YAML model. Start from a library example or draft a new device, then run it in SPX and check its behavior with your client.

You control the requirements and review the result. The model stays editable; you can inspect its attributes, behavior and protocol mappings before using it in a test.

From requirement to running device

Before you start: install SPX, start the environment and open the prepared workspace in your local AI agent. Follow the MCP connection guide if needed. The native installer prepares the workspace; you provide your own AI client.

Step 01

Describe the task

Give the agent the device requirements, protocol and response you want to test. Include a library model when one fits.
Step 02

Review the YAML

Ask the agent to inspect SPX model rules and examples. Check the proposed attributes, units, behavior and mappings.
Step 03

Run the device

Validate and register the reviewed model, create an instance and start it. Resolve connection settings from your environment.
Step 04

Check the response

Send a command through your protocol client. Compare the readback and changing model state with your requirements.

Example: an MQTT temperature sensor

Use the library's environment sensor model as a starting point. This example needs the MQTT package, a broker reachable from SPX and an MQTT client connected to that broker.

1. Give your agent a concrete task

Use SPX MCP and the environment sensor library model. Inspect its YAML and explain the temperature behavior and MQTT mappings. Prepare an instance with topic prefix spx/demo/env using my broker settings. Show the plan before creating it. Help me test a target change from 22°C to 24°C and back to 22°C. Report the topics, readbacks and observed response.

For a custom device, add its documented ranges, timing and failure behavior to the request. Ask the agent to identify assumptions and show proposed model changes before applying them.

2. Inspect the model

Check that measured temperature and target are separate attributes. This excerpt from the library YAML shows the two attributes to review; open the linked model for the full definition:

attributes:
  k__temperature_c:
    type: float
    default: 22.5
    unit: degC
  k__target_c:
    type: float
    default: 22.0
    unit: degC

The full YAML also defines the temperature dynamics and MQTT mappings. The setpoint command updates k__target_c; telemetry publishes the target and measured temperature separately. Review these parts together before running an agent's changes.

3. Verify through MQTT

Subscribe to spx/demo/env/telemetry/# before publishing. With retain=false, send plain text 24.0 to spx/demo/env/command/setpoint_c.

Success: spx/demo/env/telemetry/target_c reports 24°C, while spx/demo/env/telemetry/temperature_c changes over time. Send 22.0 to the same command topic and verify the target returns to 22°C. A successful publish alone does not confirm the device response.

SPX environment sensor chart with temperature and target in degrees Celsius, showing the 22 to 24 to 22 target sequence and measured overshoot and settling.
Recorded MQTT walkthrough using the library environment sensor. Target and measured temperature share a °C axis; time is in seconds, sampled at 1000 ms. The history is paused for inspection. Open full size

Open the MQTT walkthrough for broker settings, topic mappings and client commands. When finished, stop the instance.

Review before you rely on it

  • Behavior: check units, ranges, timing and assumptions against the source documentation.
  • Communication: verify addresses or topics, payload formats and read/write mappings with your client.
  • Repeatability: test the expected response, a failure case and recovery. Keep the reviewed YAML for reuse.

AI helps draft and refine the model. Validation still needs your engineering judgment and observed runtime results.

For other interfaces, see the Modbus, OPC UA, BACnet and KNX examples. Use the Model Language to review a draft, or Developers to explore the library and Python workflows. AI is optional; SPX also supports the browser UI and code-defined models.

Next step

Run a device you can inspect and test

Install SPX, then open the prepared workspace in your own AI agent to work with models through MCP.