Skip to content
Stand with Ukraine flag

Power Button

The Power button widget adds a single ON/OFF control to any dashboard. Use it to turn a relay on, activate a motor, or toggle any two-state device function with one click. The button reads the current device state when the dashboard loads, so what the user sees always matches the physical device.

  • Single-click ON/OFF control for any device or entity.
  • Reads current device state on load from an attribute, telemetry value, or RPC call.
  • Sends RPC commands, attribute updates, or telemetry writes independently for ON and OFF actions.
  • Multiple layout variants: Default, Simplified, Outlined, and icon-only modes.
  • Can be disabled automatically based on device data, alarms, or dashboard state.
  1. Open the dashboard in edit mode. Click Add widget in the top toolbar, or click the Add new widget icon in the center of an empty dashboard.
  2. In the widget bundle selection dialog, find and click Buttons.
  3. Select the Power button widget.
  4. Configure the datasource, behavior, and appearance, then click Add.

All settings in this section use Basic mode — a quick-start configuration covering the essentials. For finer widget controls like card style, card buttons, title, and tooltip, switch to the Advanced tab.

Select the datasource for the widget:

  • Device — a specific device; the button reads attribute and telemetry data from this device to determine its state.
  • Entity alias — a set of entities matched by an entity alias; use this when the target device is selected dynamically at runtime.

The Behavior section defines how the widget reads the device’s ON/OFF state on load, what action fires when the user presses ON, what action fires when the user presses OFF, and when the button disables. Configure each sub-section as needed; Disabled state is optional.

Determines whether the button shows as ON or OFF when the dashboard loads. Select one action type from the list below.

  • Do nothing

    The state is set manually. No live data needed.

    ParameterDescription
    ValueSet to On to always show the button as on, or Off to always show it as off.
  • Execute RPC

    Calls a device RPC method to read the current state.

    ParameterDescription
    MethodThe RPC method name to call, like getState.
    Condition (None)ON when the RPC result equals the value you specify.
    Condition (Function)ON when your f(data) function returns true.
    RPC request timeout (ms)How long to wait for a device response before timing out.
    RPC request persistentWhen enabled, the RPC command is stored and retried until the device comes online.
    Persistent polling interval (ms)How often to re-poll the device for state updates.
  • Get attribute

    Reads a device or entity attribute to determine the current state.

    ParameterDescription
    Attribute scopeWhere the attribute is stored: Any, Client, Server, or Shared.
    Attribute keyThe attribute name to read, like powerState.
    Condition (None)ON when the attribute equals the value you specify.
    Condition (Function)ON when your f(data) function returns true.
  • Get time series

    Reads the latest telemetry value to determine the current state.

    ParameterDescription
    Time series keyThe telemetry key to monitor, like state or power.
    Condition (None)ON when the telemetry value equals the value you specify.
    Condition (Function)ON when your f(data) function returns true.
  • Get alarm status

    Sets the button to ON when a matching alarm is currently active on the entity.

    ParameterDescription
    Alarm severityWhich severity levels trigger the ON state: Critical, Major, Minor, Warning, or Indeterminate.
    Alarm typesAny alarm, or a specific alarm type.
  • Get dashboard state id

    Sets the button based on the currently open dashboard state; use this when button state should reflect navigation context.

    ParameterDescription
    Condition (None)ON when the current state name matches the text you enter.
    Condition (Function)ON when your f(data) function returns true.
  • Get dashboard state object

    Sets the button based on the full dashboard state context; use this when you need to check multiple state parameters at once.

    ParameterDescription
    Condition (Function only)Write a f(data) function that returns true to set the button to ON.

Defines the action executed when the user presses the button to turn ON. Select one action type from the list below.

  • Execute RPC

    Sends an RPC command to the device when turned on.

    ParameterDescription
    MethodThe RPC method name, like setState.
    ParametersConstant — a fixed value like true, "ON", or {"state": 1}; Function — a JS function that returns the payload; None — no parameters sent.
    RPC request timeout (ms)How long to wait for a device response before timing out.
    RPC request persistentWhen enabled, the RPC command is stored and retried until the device comes online.
  • Set attribute

    Updates a device attribute when turned on.

    ParameterDescription
    Attribute scopeServer or Shared.
    Attribute keyThe attribute to update, like powerState.
    ValueConstant — a fixed value like true or "ON"; Function — a JS function that returns the value.
  • Add time series

    Writes a time-series record when turned on.

    ParameterDescription
    Time series keyThe telemetry key to write to, like state.
    ValueConstant — a fixed value; Function — a JS function that returns the value.

Defines the action executed when the user presses the button to turn OFF. Configure this as the reverse of Power ‘On’. Select one action type from the list below.

  • Execute RPC

    Sends an RPC command to the device when turned off.

    ParameterDescription
    MethodThe RPC method name, like setState.
    ParametersConstant — a fixed value like false, "OFF", or {"state": 0}; Function — a JS function that returns the payload; None — no parameters sent.
    RPC request timeout (ms)How long to wait for a device response before timing out.
    RPC request persistentWhen enabled, the RPC command is stored and retried until the device comes online.
  • Set attribute

    Updates a device attribute when turned off.

    ParameterDescription
    Attribute scopeServer or Shared.
    Attribute keyThe attribute to update, like powerState.
    ValueConstant — a fixed value like false or "OFF"; Function — a JS function that returns the value.
  • Add time series

    Writes a time-series record when turned off.

    ParameterDescription
    Time series keyThe telemetry key to write to, like state.
    ValueConstant — a fixed value; Function — a JS function that returns the value.

The Disabled state makes the button non-interactive when a configured condition is met, preventing clicks in unsafe or invalid situations.

  • Do nothing

    Set the disabled state manually. No live data needed.

    ParameterDescription
    ValueSet to True to always disable the button, or False to always keep it enabled.
  • Execute RPC

    Disable the button based on a device RPC response, like checking availability before allowing control.

    ParameterDescription
    MethodThe RPC method to call, like getAvailability.
    Condition (None)Disabled when the RPC result equals the value you specify.
    Condition (Function)Disabled when your f(data) function returns true.
  • Get attribute

    Disable the button based on a device attribute, like an online status or a locked flag.

    ParameterDescription
    Attribute scopeWhere the attribute is stored: Any, Client, Server, or Shared.
    Attribute keyThe attribute name to read, like online or locked.
    Condition (None)Disabled when the attribute equals the value you specify (String, Integer, Double, Boolean, or JSON).
    Condition (Function)Disabled when your f(data) function returns true.
  • Get time series

    Disable the button based on the latest telemetry value, like an operational mode or availability reading.

    ParameterDescription
    Time series keyThe telemetry key to monitor, like availability or state.
    Condition (None)Disabled when the telemetry value equals the value you specify.
    Condition (Function)Disabled when your f(data) function returns true.
  • Get alarm status

    Disable the button while a specific alarm is active, like blocking control while a Critical alarm is open.

    ParameterDescription
    Alarm severityCritical, Major, Minor, Warning, or Indeterminate.
    Alarm typesAny alarm, or a specific alarm type.
  • Get dashboard state id

    Disable the button based on the currently open dashboard state; use this to prevent actions in read-only or restricted views.

    ParameterDescription
    Condition (None)Disabled when the current state name matches the text you enter.
    Condition (Function)Disabled when your f(data) function returns true.
  • Get dashboard state object

    Disable the button using the full dashboard state context; use this when you need to check multiple state parameters at once.

    ParameterDescription
    Condition (Function only)Write a f(data) function that returns true to disable the button.

Controls the button’s visual style, label, and colors for each state.

SettingDescription
LayoutButton design variant: Default, Simplified, Outlined — each also available as a Volume variant (raised effect) and an Icon variant (icon only, no text label).
TitleText label displayed above the button.
Card iconIcon shown next to the title.
Button icon ‘On’Icon shown on the button in ON state.
Button icon ‘Off’Icon shown on the button in OFF state.
Power ‘On’ colorsMain — button fill color in ON state; Background — surrounding area color.
Power ‘Off’ colorsMain — button fill color in OFF state; Background — surrounding area color.
Disabled colorsMain — button fill color when disabled; Background — surrounding area color.
SettingDescription
BackgroundCard background color or image.
Show card buttonsFullscreen — expand the widget to fullscreen mode.
Card border radiusRoundness of card corners.
Card paddingSpacing between the widget content and the card border.

The Power button widget supports the Widget header button action — adds a button to the widget header that triggers a configured action when clicked.

Scenario: A Ventilation Relay device subscribes to shared attribute updates from ThingsBoard. When the shared attribute value changes, the device automatically adjusts its physical relay state. The goal is a Power button that reads the current powerState value on load, displays ON or OFF accordingly, and updates the attribute when the user presses the button.

Prerequisites:

  • Create a device named Ventilation Relay.
  • Add a shared attribute: Key — powerState, Data type — Boolean, Value — true.

Step 1. Add the widget. Open your dashboard in edit mode, click Add widget, select the Buttons bundle, then choose Power button.

Step 2. Configure the datasource. Set Target device to Ventilation Relay.

Step 3. Configure behavior.

Initial state: Get attribute — Scope: Shared, Key: powerState, Condition: None — ON when result is true (Boolean).

Power ‘On’ action: Set attribute — Scope: Shared, Key: powerState, Value: Constant — true (Boolean).

Power ‘Off’ action: Set attribute — Scope: Shared, Key: powerState, Value: Constant — false (Boolean).

Step 4. Configure appearance.

  • Layout: Outlined
  • Title: Turning Ventilation On/Off
  • Power ‘On’ colors: Main #2196F3, Background #E3F2FD
  • Power ‘Off’ colors: Main #9E9E9E, Background #F5F5F5

Step 5. Save. Click Add, resize and reposition as needed, then click Save on the dashboard toolbar.

Result: The widget reads powerState from Ventilation Relay. powerState = true — button appears blue (ON); powerState = false — button appears gray (OFF). Pressing the button writes the new value to powerState, and the device adjusts its physical relay state.

Button does not reflect device state

CauseSolution
Incorrect attribute keyVerify the key matches the device attribute exactly. Key names are case-sensitive.
Wrong attribute scopeMatch the scope to the actual attribute type (Client / Server / Shared).
No attribute on deviceOpen Devices → Attributes and confirm the key exists with a value.
RPC call failsCheck device connectivity and verify the RPC handler on the device firmware.

Button click has no effect

CauseSolution
Device offlineVerify device connectivity and transport configuration.
Wrong action typeConfirm the ON/OFF action matches how the device receives commands (RPC vs. attribute vs. time series).
RPC timeoutIncrease RPC request timeout in the behavior settings.

Button is stuck in Disabled state

CauseSolution
Disabled condition always evaluates to trueReview the Disabled state configuration — check the action type and result converter logic.
Unexpected attribute or telemetry valueOpen Devices → Attributes or Latest telemetry to inspect the actual value.