Skip to main content

switch

Add toggle switches for on/off controls on the dashboard.

Overview

The switch node adds toggle switches to your dashboard. Perfect for on/off controls, enabling/disabling features, and binary state management. Receives state updates and sends changes back to the flow.

Toggle
On/Off
2-Way
Binding
Custom
Values
Icons
Support

Properties

Property Type Default Description
group string - Dashboard group
label string "Switch" Label text
onvalue any true Value when ON
offvalue any false Value when OFF
onicon string "" Icon when ON
officon string "" Icon when OFF
topic string "" Message topic

How It Works

User Toggles Switch

When user clicks, sends configured value

// User turns ON:
{ "payload": true, "topic": "light" }

// User turns OFF:
{ "payload": false, "topic": "light" }

Receive State Update

Incoming messages update switch state

// Update switch to ON:
msg.payload = true;

// Update switch to OFF:
msg.payload = false;

Example: Smart Light Control

Control a smart light with visual feedback.

// Switch node configuration:
{
  "label": "Living Room Light",
  "onvalue": "ON",
  "offvalue": "OFF",
  "onicon": "lightbulb",
  "officon": "lightbulb_outline",
  "topic": "home/living_room/light"
}

// Flow: switch → MQTT out (to control light)
//       MQTT in → switch (to sync state)

// MQTT in receives device state and updates switch position
// User toggle sends command back to device

Custom On/Off Values

String Values

{
  "onvalue": "enabled",
  "offvalue": "disabled"
}

Number Values

{
  "onvalue": 1,
  "offvalue": 0
}

Object Values

{
  "onvalue": {"state": "on", "brightness": 100},
  "offvalue": {"state": "off", "brightness": 0}
}

GPIO Values

{
  "onvalue": 1,  // HIGH
  "offvalue": 0  // LOW
}

Pass Through Mode

Configure how incoming messages affect output.

// Pass through modes:

// 1. "never" - Only output on user click
//    Incoming messages only update display

// 2. "always" - Output on any state change
//    Both user clicks and incoming messages trigger output

// 3. "different" - Output if value changes
//    Only outputs if state actually changes

Related Nodes