Skip to content
Stand with Ukraine flag

Switch Control

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

Sends the RPC call to the device when the user toggles the switch. Appearance widget 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 needs a straightforward on-off switch wired to a device’s own RPC methods — the long-standing, directly configured form of that control, where the method names are known and no action builder is wanted.

What it does

The Switch Control toggles a device between on and off using two named RPC methods, reading the current position with one and setting it with the other. It ships wired to getValue and setValue with a 500 ms timeout, showing on and off labels beside the switch.

  • Direct RPC wiring — the get and set method names are typed in, which suits a device whose API is already fixed.
  • The switch reads its position from the device with the get method rather than assuming it.
  • On and off labels can be shown or hidden depending on whether the panel needs them.
  • A title captions the control.
  • An initial value decides what the switch shows before the first response arrives.
  • The Switch Control speaks RPC only: a switch that has to write an attribute or a time series value belongs on the Single Switch, whose actions cover all three.

How to set up

Data keys

The Switch Control takes no data keys — it communicates entirely over RPC.

MethodDirectionParametersSent when
getValueTwo-way (request-response)NoneOn load and refresh, to read the current position
setValueTwo-way (request-response)The new boolean positionWhenever the operator toggles the switch

RPC

SettingDefaultEffect
Get value methodgetValueThe method the device answers with its current state
Set value methodsetValueThe method called to change the state
Initial valuefalseWhat the switch shows before the first response
RPC request timeout500How long each call waits, in milliseconds
Switch titleSwitch controlThe caption above the switch
Show on/off labelsOnPrints the two position labels

Confirm both method names against the device’s firmware. The switch calls them exactly as written, and a mismatch leaves the control appearing to work while nothing on the device changes.

How to customize

  • To match the device’s API — set the Get value method and Set value method to the names the firmware actually implements.
  • To caption the control — set the Switch title.
  • To simplify a dense panel — turn off Show on/off labels where the switch position alone is clear.
  • To decide what shows before the first reading — set the Initial value to the safe assumption.
  • To suit a slow device — raise the RPC request timeout from its 500 ms default, which is short for anything over a constrained link.

Tips

  • Raise the request timeout for anything on a cellular or LoRaWAN link. The 500 ms default suits a wired device on a local network and will time out on a radio link that is working perfectly well, which reads to the operator as a broken switch.
  • Prefer the Single Switch on new dashboards unless RPC is genuinely the only channel. Its action-based configuration covers attributes and time series as well as RPC, and it keeps the disabled state that this control has no way to express.

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.