Skip to content
Stand with Ukraine flag

Round switch

  • Widget
  • v1.0.0
  • Sep 1, 2026
  • MIT license
  • v4.2+ | Built-in
Round switch

Sends the RPC call to the device when the user toggles the switch. Appearance settings will enable you to configure how to fetch the initial value of the switch.

Widget Type
  • Control
Category
  • Controls
Use Cases
  • Smart Home
  • Industrial Automation
  • Smart Building

Who it’s for

Anyone who wants a compact round on-off control wired directly to a device’s RPC methods, or reading its position from an attribute or a telemetry key. The footprint is small enough to sit in a corner of a mimic diagram rather than in a control panel row.

What it does

The Round switch toggles a device between on and off using a compact circular control in a 2.5×2 tile. It ships wired to the setValue RPC method for commands, and its position can be read back over RPC or from the value attribute or telemetry key, with parse and convert functions translating between the device’s values and the switch’s boolean.

  • A small circular control that fits where a full switch row would not.
  • The position can be read from RPC, an attribute or a time series key, selected by the retrieve method.
  • A parse function converts whatever the device reports into the boolean the switch shows, and a convert function shapes what is sent.
  • The value key is configurable, so the switch can follow any attribute rather than a fixed name.
  • An initial value decides what the switch shows before the first response arrives.
  • The Round switch is one control for one thing: a value rather than a state belongs on a knob or a slider.

How to set up

Data keys

The Round switch takes its state from RPC or from the configured value key rather than from the datasource key list.

AttributeScopeOperationDescription
valueAnyReadRead when Retrieve value method is set to an attribute or time series source rather than to rpc.
MethodDirectionParametersSent when
getValueTwo-way (request-response)NoneOn load, when the retrieve method is rpc
setValueTwo-way (request-response)The result of the convert value functionWhenever the operator toggles the switch

RPC

SettingDefaultEffect
Retrieve value methodrpcWhere the position is read from — RPC, an attribute or a time series key
Get value methodgetValueThe RPC method answering with the current state
Set value methodsetValueThe RPC method called to change the state
Value keyvalueThe attribute or telemetry key read when not using RPC
Parse value functionreturn data ? true : false;Converts the device’s value into the switch’s boolean
Convert value functionreturn value;Shapes the value sent to the device
Initial valuefalseWhat the switch shows before the first response
RPC request timeout500How long each call waits, in milliseconds
Switch titleRound switchThe caption on the control

How to customize

  • To follow a reported attribute instead of polling — set the Retrieve value method to the attribute or time series source and name the Value key.
  • To match the device’s API — set the Get value method and Set value method to the names the firmware implements.
  • To handle a non-boolean state — edit the Parse value function, which is where a device reporting "ON" or 1 is translated.
  • To send something other than a plain boolean — edit the Convert value function.
  • To caption the control — set the Switch title.
  • To suit a slow device — raise the RPC request timeout from its 500 ms default.
  • To decide what shows before the first reading — set the Initial value to the safe assumption.

Tips

  • Read the position from an attribute rather than by RPC wherever the device already reports it. A subscription updates the moment the device changes, while an RPC read only refreshes when the widget asks, so a switch operated from elsewhere stays wrong until the dashboard is reloaded.
  • Raise the timeout well above 500 ms on any radio link. That default suits a wired device on a local network, and on a cellular or LoRaWAN device it produces timeouts that look like faults rather than latency.

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.