Skip to content

Sending Commands

Send a value to a device’s sensor and get confirmation back once the device has applied it — sometimes called a cloud-to-device (C2D) command.

With the Node.js SDK, attach a listener for the command event — this automatically subscribes the device, no separate call needed:

device.on('command', (command, ack) => {
console.log(command.sensorId, command.value)
// ...apply it — flip a relay, change a mode, etc...
ack({ success: true, value: command.value })
})

Call ack() once you’ve actually applied the command — the platform is waiting on it to know the command really happened, not just that it arrived.

The Embedded C SDK works the same way through a callback, and also runs a command only once if it’s delivered twice. With the Node.js SDK, make your handler safe to run twice, using command.commandId to spot a repeat.

If a device’s connection drops only briefly, a command sent in that moment is delivered when it reconnects. Once the platform has marked a device offline, new commands are refused with Device offline rather than held, including for a device in deep sleep. To control a device that sleeps, send the command while it’s awake.

On a sensor’s page — for any sensor set up to Receive or Exchange commands (see Device Provisioning) — you’ll find a control instead of a static value:

  • A binary sensor gets a toggle switch.
  • A state sensor gets a text field and a Send button, since its values aren’t limited to on/off.

Both send as soon as you interact with them — there’s no separate confirm step.

While a command is in flight, you’ll see one of:

  • Sending…
  • Confirming with device…
  • Command timed out
  • Command failed
  • Device offline — shown immediately if the device wasn’t reachable to send to.
  • Failed to send command — a generic send error.

A “Command timed out” message isn’t necessarily the final word — the device may still apply the command and the platform record it as confirmed shortly after. If you’re not sure, revisit the sensor’s page to check its current state.

Every confirmed change to a sensor’s state — whether from a command you sent, an automation, or the device itself — appears in a history table on the sensor’s page: the value change, who or what made it (a team member’s name or an automation’s name), and when. A command that failed or timed out without ever being confirmed doesn’t appear here — only the transient status message you saw while sending it.

A Send-direction sensor is report-only — its page shows a read-only value instead of a control, with a note that it can’t receive commands.

  • Device Provisioning — sensor types and data direction, which determine what can receive a command.
  • Sensor State — when the device changes a value itself.
  • Automations — sending commands automatically as part of a workflow.
  • Telemetry — publishing and querying the sensor data your commands often act on.