Send to client
Sends a command to one client, like switching a relay on. If the client is offline the command waits for it. Turn on Wait for confirmation and the step leaves by what became of the command.
action:clientMessageHow it looks
With Wait for confirmation on, the step has three ways out instead of default, and each can lead somewhere different.
Settings
| Setting | Required | What it does |
|---|---|---|
| Client | Yes | The client to send to. Pick one, or use a value from the run such as trigger.clientRefId to answer whoever started it. |
| Command type | Yes | The command name, like relay.set. 1–100 characters. Can't start with sys. or be capabilities or state.report. |
| Payload | No | Any JSON, up to 64 KB. Values from the run can be placed in it. |
| Wait for confirmation | No | Off by default. When on, the step waits for the client's sys.ack and leaves by acked, failed or timeout. |
| Timeout | No | How long to wait for the confirmation. 30 seconds when unset, at most the command's 24-hour lifetime. The command expires when the step stops waiting. |
Ports
| Port | When |
|---|---|
default | Wait for confirmation is off. The run moves on as soon as the command is queued. |
acked | The client confirmed it received the command. This is delivery, not success: report the outcome as a reading if it matters. |
failed | The client refused it, for example because it arrived after expiresAt. |
timeout | No confirmation arrived in time. The command expires, so the client won't act on it later. |
What it adds to the run
| Value | Holds |
|---|---|
command | With Wait for confirmation on: what became of the command, so a later node can tell acked from timeout. |
On the board
The SDKs confirm delivery for you. Check for the command type in your message handler; it runs when the command arrives.
wbskt.onMessage([](const WbsktMessage& message) { if (strcmp(message.type, "relay.set") == 0) { bool on = message.payload["on"] | false; digitalWrite(PUMP_PIN, on ? HIGH : LOW); } });
wbskt.OnMessageReceived += (type, payload, commandId) =>
{
if (type == "relay.set")
pump.Switch(payload);
};def handle(message): if message.type == "relay.set": pump.value = message.payload["on"] client.on_message = handle
Problems you might see
| Code | Means |
|---|---|
CLIENT_MESSAGE_NO_TARGET | Client filled in to something that isn't a client reference. |
CLIENT_MESSAGE_INVALID | The command type is missing or reserved, or the payload is too large. Shown when you publish. |
CLIENT_MESSAGE_ACK_TIMEOUT | The timeout is out of range. Shown when you publish. |
COMMAND_PUBLISH_ERROR | The command couldn't be queued. Retryable. |
Sending a command from the API instead has its own codes, like COMMAND_TYPE_RESERVED and CLIENT_INACTIVE, on the error codes page.
See also
Starts when a client sends a message of a type you pick, optionally only when its values match, or have matched for a while.
Outdefaulttrigger:clientPauses the run for a fixed time. Waiting costs nothing.
Outdefaultcontrol:delayChecks a condition, or several joined with and or or, and leaves by true or false.
Outtruefalsecontrol:logic