Switch

Docs / Widgets / Controls / Switch
Control widget

Switch

A Switch turns something on or off: a relay, a pump, a light. Tap it once to switch on, tap again to switch off. It stays where you leave it.

Dashboard → deviceSends 1 / 01 Telemetry Point8 knob icons

Try it

Tap the switch on the dashboard. Watch the value travel to the NuttyFi board and the relay LED change. Then change the settings below — they are the same ones you'll find in the widget's settings window.

SimulationLIVE
Dashboard
This is the real Switch widget from the dashboard.
Your device
NuttyFiMCU · Wi-Fi ONLINE TP0 Pump: OFF NUTTYFI
The board reads the Telemetry Point and switches the relay.
Switch Orientation
Icon
Widget Color
Show
A Switch sends a commandIt shows the state you asked for. To show what the device actually reports, add an LED or Value widget on a Telemetry Point the device writes.

How to add and set up

  1. Open the dashboard in edit modeOpen the device and turn on editing.
  2. Add a SwitchPress + on the right edge of the canvas and pick Switch. Drag it into place.
  3. Open its settingsClick the gear icon on the widget. The window title shows the widget's name.
  4. Link a Telemetry PointUnder Linked Telemetry Points, pick the point your code reads, for example TP0.
  5. Name and style itSet the Widget Name, Switch Orientation, Icon, labels and Widget Color. Save, then press DONE.

Settings

SettingWhat it does
Widget NameThe title shown on the widget.
Label ColorColour of the title.
Linked Telemetry PointsThe Telemetry Point (TP0, TP1…) the widget uses. Your device code uses the same point.
Switch OrientationHorizontal or Vertical. The tile keeps the same size; the switch turns upright.
IconSymbol on the knob: Auto (power), Power, Bulb, Fan, Pump / Water, Lock, Bell or Play / Pause.
ON / OFF labelText shown under the switch for each state. Defaults: ON and OFF.
ON / OFF text colourColour of that text in each state.
Widget ColorColour of the switch (and its glow) when it is on, and of the tile's border.
Hide widget NameHides the title.
Hide Telemetry PointHides the TP badge in the corner.
Hide Widget BorderRemoves the outline around the tile.

What it sends

Each tap writes one value to the linked Telemetry Point. Your device code checks that point and switches the pin.

1
ONSwitch turned on
0
OFFSwitch turned off
Wire relays safelyWhen a Switch drives mains power through a relay, use a proper relay module and keep high-voltage wiring away from the board.

Receive commands on your device

Your board picks the value up with SME_LISTEN, using the same point you linked on the dashboard. The examples use TP0.

C++ · Arduino
SME_LISTEN(TP0)
{
  int on = data.toInt();        // 1 = on, 0 = off
  digitalWrite(PUMP_PIN, on);
}

SME_LISTEN(TP0) runs every time the dashboard writes TP0. data holds the value it sent, as text: use data.toInt() for whole numbers or data.toFloat() for decimals.

These are snippets. Your sketch also needs #include <SMEIoT.h>, SME.begin(...) in setup() and SME.run() in loop(). The full sketch tab shows a complete example; see the SDK quick start for more.

Was this page helpful?