Capabilities
Switch
Domain switch: states, services, device classes and features.
Entity ids in this domain look like switch.<object_id>.
Use in preferences
{ key: 'device', label: 'Device', type: 'entity', domainFilter: 'switch', required: true }States
getState() returns the raw token. subscribe filters, entity.is() and matchesState() also accept the friendly label the app shows (any case; spaces, hyphens and underscores interchangeable).
| Device class | on | off |
|---|---|---|
| any | On | Off |
subscribe($g.device, { to: 'on' }, onChange);
subscribe($g.device, { to: 'On' }, onChange); // same thing, by label
if ($g.device.is('On')) { /* … */ }Services
Curated for smart apps (also offered by the wizard action catalog):
| Service | Parameters | Description |
|---|---|---|
toggle | — | Toggle |
turnOff | — | Turn off |
turnOn | — | Turn on |
await $g.device.toggle();Device classes
none, switch, outlet, plug, relay, fireplace
Filter with deviceClassFilter in an entity input.