Define the device once. Run and refine it.
An SPX model describes a virtual device in a structured definition: its values, behavior and communication. Keep it as YAML alongside your project, review changes with your team and reuse the definition to create device instances.
Start from a library model, write your own, or ask your AI agent to help. The definition stays available to inspect and edit.
What goes into a model?
- Attributes hold values such as temperature, humidity and battery level.
- Actions describe how values change as the model runs.
- Communication maps the model to a protocol such as MQTT or Modbus.
- Scenarios, when needed, apply repeatable changes to exercise an operating condition or fault.
Example: a temperature and humidity sensor
In our local Shelly Plus H&T-inspired demonstration, temperature, humidity and battery level are numeric model attributes. A separate simulation target lets us change the environment and watch the temperature respond. The MQTT adapter publishes selected values in device-style JSON messages.
This excerpt is from the model used for the run below; it shows the state and one action, not the complete model or its MQTT configuration:
attributes:
k__temperature_c: 21.0
k__target_temperature_c: 26.0
k__humidity_percent: 47.2
k__battery_percent: 82.0
actions:
- function: $in(k__temperature_c)
name: approach_target
call: $in(k__temperature_c) + 0.04 * ($in(k__target_temperature_c) - $in(k__temperature_c))
The action moves the simulated reading toward the target on each model cycle. In the complete demonstration, separate actions format the MQTT status payloads. The target is a simulation control; it is not a feature claimed for the physical sensor.
Connect the model to MQTT
The communication block links a model attribute to a topic. In the tested example, an action formats the numeric k__temperature_c as a Shelly-style JSON message in the helper attribute _temperature_status. The MQTT binding then publishes that helper:
communication:
- mqtt:
broker: host.docker.internal
port: 1883
topic_prefix: shellyplusht-numeric-demo
bindings:
- name: publish_temperature
attribute: $ext(_temperature_status)
topic: status/temperature:0
direction: publish
The resulting topic is shellyplusht-numeric-demo/status/temperature:0. The broker address is specific to our local demonstration; use settings reachable from your SPX environment. The example omits other bindings and adapter settings for clarity.
See the model definition reference for the full set of model sections, attribute definitions and configuration options, and the MQTT Quickstart for connection and client examples.

We verified that a local MQTT broker received valid JSON messages for temperature, humidity and battery as values changed. This is a simplified demonstration based on selected status topics, not a full compatibility test against a physical Shelly device. Explore the AI-assisted example for the task and test context.
From definition to test
- Choose a starting point: browse the model catalog or describe a device to your agent.
- Review and adapt: check attributes, units, actions and protocol mappings against your requirements. Keep environment-specific endpoints configurable.
- Run and verify: load the model, start an instance and observe its behavior in SPX. Test protocol messages with a client; a running instance alone does not prove interoperability.
- Keep the definition: save and version the reviewed YAML with your project so the team can inspect and reuse it.
When it helps
- Review behavioral and protocol changes alongside application code.
- Reuse a device definition across local development and automated tests.
- Refine an AI-generated model using the same engineering review process.
