Why build with Things
Whether you run ten identical sensors on a factory floor, a fleet of solar inverters across a substation, or hundreds of street lights across a city district, copying and pasting separate connectors, models, and actions quickly becomes hard to maintain. With a Thing, you describe the asset once as a template and deploy as many instances as you need from a root.When to use these patterns
The examples below are complete and ready to deploy. Send each block to
$SYS/Coreflux/Command with -addThing, or test it first with -addThing --dryRun to inspect the expanded children without changing the broker.
Two sensors on one machine
Start with the simplest pattern: aTempSensor template with a default alarm limit, and an Oven root that creates two sensors (inlet and outlet). The outlet sensor overrides the default limit of 80 with 120:
TempSensor is stored as a template and Oven expands into four children:
Double braces like
{{path}} and {{limit}} are replaced when the broker expands the Thing. Single braces like {temp} are runtime action variables and stay untouched.Reusable PLC template
When a whole machine is one instance of a template, useDEFINE THING <name> OF <template> to deploy it directly without an extra nesting level.
Here, the plc template bundles a Modbus TCP connector, a status model, a heartbeat action, and an access rule. press1 and press2 stamp out two presses with different IP addresses:
ip has no default value in plc, every root must pass WITH PARAM ip. The slave parameter defaults to 1 unless overridden.
Helper action inside a Thing
Clauses inside the same Thing can refer to each other by their short local name. The broker rewrites those references to the expanded child names automatically. In this example,OnReading calls the sibling callable action Normalize to scale a raw sensor reading by 0.1 before publishing:
tank1 is deployed, CALL ACTION Normalize is rewritten to CALL ACTION tank1_level_Normalize. Publishing 250 to tank1/level/raw publishes 25 to tank1/level/value.
Production line with multiple machines
Templates can instantiate other templates to model physical hierarchies such asfactory → line → press.
This example builds on the plc template above. Each line has two presses, and each press derives its IP address from its line’s baseIp parameter ({{baseIp}}.11 and {{baseIp}}.12):
press declares WITH PARAM ip and does not need to pass it to controller: required parameters automatically inherit from the nearest enclosing instance that defines them.
Intelligent Things
A Thing can bundle an AI agent (WITH AGENT), a diagnostic action (CALL AGENT), and a dashboard (WITH PANEL) inside the same template, turning a physical machine into an Intelligent Thing. When you nest Intelligent Things inside a parent station, a station supervisor agent can delegate to each child’s agent using relative dotted paths (WITH AGENTS "p1.Assistant, p2.Assistant").
- Single intelligent asset
- Station supervisor with intelligent assets
Use Deploying
WITH PARAM llm AS CONNECTOR to pass an existing TYPE LLM connector into the template. Before deploying this example, make sure the PlantLLM connector and the broker user agent-north exist on your broker:north creates:north_p1_Assistant(AGENT): scoped to read onlynorth/p1/#topics, using the sharedPlantLLMconnector.north_p1_DiagnoseAlarm(ACTION): callsnorth_p1_Assistant.executewhenever an alarm arrives onnorth/p1/alarmand publishes the advice tonorth/p1/advice.north_p1_Dashboard(PANEL): a published dashboard titled"Pump p1"bound tonorth/p1/advice.
Energy use cases
Power grids, renewable generation sites, and EV charging hubs all rely on repeated assets that share the same telemetry schema and safety rules.- Solar farm inverters
- EV charging hub
Poll multiple solar inverters over Modbus TCP, publish a unified telemetry model for each inverter, and raise an alarm if grid frequency drops below a safe threshold (Setting
minFreq, default 49.8 Hz):WITH PARAM path "grid/solar/west" on the solar_west root places all inverter topics under grid/solar/west/inv1/… and grid/solar/west/inv2/…:Smart cities use cases
Municipal IoT deployments manage identical sensors and controllers across streets, parks, and school zones, where only topic paths or safety thresholds change per location.- Smart street lighting
- Urban air quality network
Adjust street light brightness automatically from ambient light (When ambient light on
lux) readings. Pedestrian crossings or park avenues can override luxThreshold to turn on earlier at dusk:city/lights/downtown/park_ave/lux drops below 50, downtown_lights_park_ave_AutoDim sets brightness to 100%; on main_st, it waits until light drops below 30.Verify your deployment
1
Preview with a dry run
Send
-addThing --dryRun <DEFINE THING …> to $SYS/Coreflux/Command. The response on $SYS/Coreflux/Command/Output shows every child (add, update, adopt, remove, or unchanged) and its expanded LoT code without modifying the broker.2
Deploy the Thing
Send
-addThing <DEFINE THING …> to $SYS/Coreflux/Command. All children deploy together as one atomic unit.3
Inspect the live tree and status
Use MQTT Explorer or Coreflux HUB to subscribe to
$SYS/Coreflux/Things/<name>/tree (the expanded instance tree) and $SYS/Coreflux/Things/<name>/status (ok, degraded, or error).Best practices
Use double braces for parameters and single braces for runtime variables
Use double braces for parameters and single braces for runtime variables
Write
{{limit}} and {{path}} for Thing parameters replaced at deploy time. Keep single braces like {temp} for runtime action variables and {payload} for connector event placeholders.Edit children through their Thing
Edit children through their Thing
Children deployed by a Thing are protected against direct edits. To change a child action, model, or connector, update the
DEFINE THING source and run -addThing again.Keep secrets out of Thing parameters
Keep secrets out of Thing parameters
Resolved parameter values are published on
$SYS/Coreflux/Things/<name>/tree. Always read credentials inside clause bodies with GET SECRET or GET ENV instead of passing them through WITH PARAM.Next steps
Thing Syntax
Full reference for templates, clauses, parameters, references, and permissions.
Things Overview
Learn how Things group assets and how
-addThing manages their lifecycle.
