Skip to main content

Segmented Control Widget

⚡ Control

The Segmented Control renders N labeled buttons in a row — only one can be active at a time. Selecting a segment sends its associated value to the device. Useful for mode selection: Auto/Manual/Off, Low/Medium/High, or any discrete-state machine.

Default size: 3 × 2 grid cells


Configuration

PropertyTypeDefaultDescription
options{label, value}[][{label:"Off",value:"0"},{label:"On",value:"1"}]Segment labels and values
colorhex color#6366F1Active segment highlight
DevicedeviceThe device to write to
PinV0V255The virtual pin to write
LabelstringWidget label

Example options

Fan speed

[
{ "label": "Off", "value": "0" },
{ "label": "Low", "value": "1" },
{ "label": "Med", "value": "2" },
{ "label": "High", "value": "3" }
]

Thermostat mode

[
{ "label": "Cool", "value": "cool" },
{ "label": "Heat", "value": "heat" },
{ "label": "Fan", "value": "fan" },
{ "label": "Auto", "value": "auto" }
]

Firmware example

VWIRE_RECEIVE(V0) {
int mode = param.asInt(); // 0=Off, 1=Low, 2=Med, 3=High

switch (mode) {
case 0: setFanSpeed(0); break;
case 1: setFanSpeed(85); break;
case 2: setFanSpeed(170); break;
case 3: setFanSpeed(255); break;
}
Vwire.virtualSend(V0, mode); // echo active segment
}

String values

VWIRE_RECEIVE(V1) {
String mode = param.asStr(); // "cool", "heat", "fan", "auto"
setThermostatMode(mode);
}

Tips

  • Keep labels short (1–5 chars) — the segments divide the widget width equally.
  • For more than 5 options, consider a Number Input or LCD + Step Control combo.
  • Echo the value back with virtualSend so the segment stays highlighted after a page reload.