IMD SolutionComputing LibraryShop main store

Troubleshooting

Fix an empty MQTT template variable in a robot controller

Edge computing and IIoT Published 5 min read

Short answer

When the ControllerExecutionState substitution publishes empty on the IoT Data Gateway MQTT publisher while the timestamp, alias and operating-mode substitutions resolve, the substitution itself has failed, not the publisher. Replace it with the Rapid.Tasks.T_ROB1.ExecutionStatus substitution, the execution status of RAPID task T_ROB1, and verify it against observed task behavior.

On this page
  1. Why does one MQTT template variable come through empty?
  2. Is an empty ControllerExecutionState proof the program stopped?
  3. Which variable reports whether the RAPID program is running?
  4. How do I swap the variable into the publisher template?
  5. How do I verify the field tracks the real task?
  6. What if the field is still empty after the change?
  7. Can this MQTT field drive an alarm or an interlock?
  8. Questions asked

When {{ControllerExecutionState}} publishes as an empty string while {{Now}}, {{Alias}} and {{OperatingMode}} resolve, the publisher and its broker path are fine and that one substitution is not. On the IoT Data Gateway MQTT publisher, reported on RobotWare 6.15.02, the fix that works is to stop asking the controller-level variable and read the task instead: {{Rapid.Tasks.T_ROB1.ExecutionStatus}} for RAPID task T_ROB1. What follows is the isolation, the edit, the verification against real task behavior, and the one thing an empty value must never be used for.

Why does one MQTT template variable come through empty? #

Because that single substitution fails to resolve at publish time: the publisher still builds the rest of the message, leaves the unresolved field as an empty string, and sends it anyway, so the fault sits in variable resolution, not in the broker path.

The reported template carries four substitutions in one message, and only one of them fails:

Substitution Reported result Role in the message
{{Now}} Resolves Timestamp
{{Alias}} Resolves Controller identity
{{OperatingMode}} Resolves Operating mode
{{ControllerExecutionState}} Empty Controller-level execution state

Because all four ride in the same message, one empty field tells you three things at once:

  • The connection, the topic and the message structure are proven by the messages that arrive fully formed.
  • The fault is inside the publisher, at the lookup of that one name.
  • The root cause is not established by the report — misconfiguration, a documentation mismatch and a version-specific defect on RobotWare 6.15.02 are all open — but the repair does not depend on it.

The publisher-versus-broker split is the first cut on any gateway; for the same isolation worked on a router-based publisher, see troubleshooting a RUT241 MQTT publisher against a Home Assistant broker. If your symptom is different — stray characters or broken structure inside the JSON instead of a well-formed message with an empty field — you have a payload problem, not a resolution problem; start with fixing extra characters in a PLC MQTT JSON payload.

Is an empty ControllerExecutionState proof the program stopped? #

No. An empty substitution means the value never resolved, so it carries no information about execution at all: it cannot distinguish running from stopped, and treating it as a stopped indication would make every resolution failure look like a stopped program.

The publisher is saying "no value", not "not running". Downstream, the empty field causes its own trouble: consumer-side templates throw warnings whenever a payload arrives without the values the template names, the same behavior other integrations report with empty fields. Show unknown on the dashboard, and keep the empty case out of anything that acts on program state.

Which variable reports whether the RAPID program is running? #

{{Rapid.Tasks.T_ROB1.ExecutionStatus}}, the execution status of RAPID task T_ROB1 — the task-level path the reported setup settled on, and the level you actually want when the question is whether the program in a specific task is executing.

"Is the program running" is a per-task question. A controller can hold more than one RAPID task, and the state you want belongs to the task that holds the program you care about. T_ROB1 is the task name in the reported configuration, not a universal one: read the exact name from your controller's task configuration and use it in the path. If you need more than one task, give each its own substitution and its own field in the message.

How do I swap the variable into the publisher template? #

Change only the failing substitution: leave the other three lines alone and replace {{ControllerExecutionState}} with {{Rapid.Tasks.T_ROB1.ExecutionStatus}}, so the published field carries the task's execution status instead of the controller-level state.

{
  "StatusMessage": {
    "Timestamp": "{{Now}}",
    "Name": "{{Alias}}",
    "Mode": "{{OperatingMode}}",
    "ProgramStatus": "{{Rapid.Tasks.T_ROB1.ExecutionStatus}}"
  }
}

Only the ProgramStatus line changes. The JSON keys around it are the message shape from the reported template, not fixed names — keep whatever your consumer already parses.

How do I verify the field tracks the real task? #

Watch the published field while you deliberately start and stop the task it names: a working substitution is populated on every message and changes in step with the task, in the same cadence as the timestamp that already resolves.

  • Confirm messages still arrive; the three resolving substitutions prove the path on every publish.
  • With the task stopped, record what ProgramStatus publishes.
  • Start the task and confirm the value changes and stays populated across several consecutive messages, not just the first one.
  • Stop the task again and confirm the value returns to the stopped indication you recorded.
  • Check that {{Now}} advances across those same messages, so you are reading fresh publishes rather than a retained one.

Verification is that observed correspondence — the field moving with the task through a start and a stop — not the variable name on the page.

What if the field is still empty after the change? #

Then the task path does not match your controller: the substitution names one specific RAPID task, and a path that does not point at a task that exists exactly as spelled gives you nothing to read, so the task name is the first thing to confirm.

Check the spelling against the controller's task configuration, then confirm you are watching the right controller — {{Alias}} in the same payload names the publisher. If the name is right and the field still resolves empty, the documented trail ends: the cause behind the controller-level variable was never established on RobotWare 6.15.02, so take it to the vendor's support channel with your version and template. And if messages stop reaching the consumer altogether instead of arriving with an empty field, that is a subscriber-side fault — start with fix MQTT sensor data missing in Node-RED.

Can this MQTT field drive an alarm or an interlock? #

For alarms and dashboards, yes, once the field is verified against observed task behavior; for anything that must stop the machine, no — an MQTT publish through a gateway is neither fast enough nor validated as a safety channel, and stop functions belong to the controller's own safety chain.

In SCADA use, give the empty case its own communications alarm so a failed substitution cannot masquerade as a program state. Sequence and interlock logic reads the controller directly.

Questions asked

Does an empty field make the MQTT message invalid?

No. The JSON stays well-formed with an empty string in that field, and the message still publishes. The damage is downstream: templates and tag mappings that expect a value can throw errors or leave points blank when the field arrives empty, which is why the empty case needs its own handling in the consumer.

Should the subscriber hold the last value when the field comes back empty?

Hold the last known value and flag it as stale, rather than writing a stopped state or a zero. An empty field means the substitution failed, so overwriting a good last value destroys real information. Alarm on the empty condition itself so someone sees the broken substitution.

Will changing one substitution break the fields that already work?

No. In the reported case three substitutions resolve while a fourth comes back empty inside the same message, which shows each name is resolved on its own, so editing one line leaves the others untouched. Verify on the next publish anyway: if all four go empty at once, you have a publisher or path fault, not a single failed variable.

What should I collect before raising this with the vendor?

Four things: the RobotWare version exactly as installed, the template text as configured, one published message showing the empty field alongside the resolving ones, and the task name from your controller's configuration. That package lets support reproduce the substitution without a site visit.

Keep reading

  • How-to

    Bridging OPC UA PLC data to MQTT with an edge PC

    Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.

    Edge computing and IIoT

  • Troubleshooting

    Fix MQTT sensor data missing in Node-RED

    A green MQTT connection in Node-RED proves only a broker session, not that the GSM module published a value or that the flow subscribes to its topic. An http in node cannot receive MQTT publications at all: use an mqtt in node. Trace RS-485 acquisition, publish result, broker identity and topic match in order, and fix the first stage with no positive result.

    Edge computing and IIoT

  • How-to

    Sending PLC data to an IoT hub without custom software

    You do not need custom software to move PLC data to an IoT hub: a configurable edge package with an S7, Modbus TCP or EtherNet/IP driver, a channel mapping and an MQTT publisher replaces hand-written acquisition code. Verify two things before you commit: the driver covers the protocol your controller actually speaks, and the publisher covers the destination's authentication and message format. Software still does the work — you configure it instead of writing it.

    Edge computing and IIoT