Segmented Control Widget
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
| Property | Type | Default | Description |
|---|---|---|---|
options | {label, value}[] | [{label:"Off",value:"0"},{label:"On",value:"1"}] | Segment labels and values |
color | hex color | #6366F1 | Active segment highlight |
| Device | device | — | The device to write to |
| Pin | V0–V255 | — | The virtual pin to write |
| Label | string | — | Widget 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
virtualSendso the segment stays highlighted after a page reload.