Power button
Sends the command to the device or updates attribute/time series when the user pushes the button. Widget settings will enable you to configure behavior how to fetch the initial state and what to trigger when power on/off states.
Who it’s for
Anyone who needs a dashboard to turn equipment on and off and to show which it currently is — a pump, a light circuit, a heater, a machine. The control is the familiar power symbol, and it has to reflect the device rather than the last thing the operator pressed.
What it does
The Power button turns equipment on and off, showing its current state as a lit or unlit power symbol. The state is fetched by a configured action, the on and off transitions each send their own action, and all three are independent, so the button can read an attribute and command over RPC.
- State is read back, not assumed — the initial state action fetches from an attribute, a telemetry key, an RPC call or an alarm status, so the button reflects the equipment.
- On and off are separate actions, which matters for devices where turning on and turning off are different calls rather than one call with a flag.
- A disabled condition greys the button out, distinguishing “off” from “cannot be operated right now”.
- On, off and disabled each carry their own main and background colors, so the three states are visually distinct rather than shades of one.
- Persistent RPC is supported with a polling interval, for devices that acknowledge asynchronously.
- The Power button is one control for one thing: several circuits need several buttons, and a value rather than a state belongs on a slider or a stepper.
How to set up
Data keys
The Power button takes no data keys — state and commands come from its configured actions.
| Attribute | Scope | Operation | Description |
|---|---|---|---|
| Configured key | Any for read, Shared / Server for write | Read + Write | With Initial state set to Get attribute the button reads this key; with the on and off actions set to Set attribute it writes it. |
| Method | Direction | Parameters | Sent when |
|---|---|---|---|
| Power on method | One-way or two-way, as configured | Constant or from a convert function | When the operator switches the button on |
| Power off method | One-way or two-way, as configured | Constant or from a convert function | When the operator switches the button off |
Behavior
| Setting | Default | Effect |
|---|---|---|
| Initial state | Unset | How the current state is fetched — Execute RPC, Get attribute, Get time series or Get alarm status |
| Power ‘On’ | Unset | The action performed to turn the equipment on |
| Power ‘Off’ | Unset | The action performed to turn the equipment off |
| Disabled state | Unset | An action deciding when the button cannot be pressed |
| RPC request persistent | Off | For devices acknowledging asynchronously, with a polling interval |
Configure the initial state action even when the on and off actions are enough to operate the device. Without it the button shows whatever it was last set to, which drifts out of step with the equipment as soon as anything else changes it.
How to customize
- To read the real state — set Initial state to the action that matches how the device reports, and supply a parse function if the value is not already a boolean.
- To command the device — set Power ‘On’ and Power ‘Off’ to their own actions, which may be two different RPC methods.
- To block operation under a condition — configure the Disabled state action.
- To make the three states unmistakable — set the Power ‘On’ colors, Power ‘Off’ colors and Disabled colors, each with a main and a background color.
- To fit the tile — set Layout, and the card background and padding.
- To support a slow device — turn on RPC request persistent and set the polling interval.
Tips
- Give the disabled state a color that reads as neither on nor off. Operators learn two colors quickly and then stop reading the tile, so a disabled button tinted like the off state gets pressed and reported as broken.
- Configure the initial state from the device’s own reported state rather than from the attribute the button writes. Writing and reading the same key makes the button agree with itself even when the equipment never acted on the command.
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.