Command button
Allows single-click commands to devices or updates to attributes/time series. Settings enable definition of the on-click action and condition when the button is disabled. Supports multiple layouts and custom styles for different states.
Who it’s for
Anyone who needs a dashboard to do one thing on demand — reboot a gateway, trigger a calibration, acknowledge a state, write a setting. The action is momentary and has no on and off: the operator presses once and something happens on the device.
What it does
The Command button sends a single configured action when clicked. That action can call an RPC method on the device, set an attribute, or write a time series value, so the same button reboots a controller or records a manual reading depending only on how it is configured.
- One click, one action — no state to keep in sync, which is what makes this the right control for anything momentary.
- Three kinds of action: an RPC method, an attribute write, or a time series write, chosen per button.
- The value sent can be a constant or computed by a function, so a button can stamp the current time or derive a payload rather than always sending the same thing.
- A separate disabled condition greys the button out from an attribute, a telemetry key, an RPC result or an alarm status, so an unsafe command can be blocked while a condition holds.
- Persistent RPC is supported with a polling interval, for devices that acknowledge asynchronously.
- The Command button reflects nothing back: it shows no device state, so a control that must also indicate whether the thing is on belongs on a switch or a status tile.
How to set up
Data keys
The Command button takes no data keys — what it sends comes from its configured action.
| Attribute | Scope | Operation | Description |
|---|---|---|---|
| Configured key | Shared / Server | Write | With On click set to Set attribute, the button writes this key in the chosen scope. Add time series writes a telemetry key instead. |
| Method | Direction | Parameters | Sent when |
|---|---|---|---|
| Configured method | One-way or two-way, as configured | Constant or returned by a convert function | With On click set to Execute RPC, on every click |
Behavior
| Setting | Default | Effect |
|---|---|---|
| On click | Unset | The action performed — Execute RPC, Set attribute or Add time series |
| Value | Constant | What is sent; a Convert value function can compute it instead |
| Disabled state | Unset | An action deciding when the button is greyed out |
| RPC request timeout | Platform default | How long a two-way call waits |
| RPC request persistent | Off | For devices acknowledging asynchronously, with a polling interval |
Configure the disabled state for anything that should not be pressed twice or pressed in the wrong condition. A button with no disabled rule is always pressable, and the device is the only thing standing between an operator and a repeated command.
How to customize
- To choose what the click does — set On click to Execute RPC, Set attribute or Add time series, then fill in the method or key.
- To send something computed — supply a Convert value function instead of a constant, which is how a button stamps a timestamp or builds a payload.
- To block the command under a condition — configure the Disabled state action against an attribute, a key, an RPC result or an alarm status.
- To support a slow device — turn on RPC request persistent and set the polling interval.
- To fail faster on an unreachable device — lower the RPC request timeout.
- To label the action — set the button’s appearance text to the verb the operator would use.
Tips
- Label the button with what happens, not with the mechanism. Reboot gateway tells an operator what they are about to do; Send RPC tells them only that something will be sent.
- Put a status tile or an LED beside any button whose command has a visible effect. A momentary button gives no feedback by design, and without an indicator an operator has no way to distinguish a command that worked from one that timed out.
Share Your Widget with the Community
Built a custom widget? Export it as a JSON from ThingsBoard and publish it to the IoT Hub through a simple 4-step wizard (Upload, Listing, Readme, Review & Submit). Share it with thousands of ThingsBoard developers worldwide and get featured in the catalog.