switch
Generic on/off switch cap for accessory children (siren, floodlight, spotlight, PIR toggle, chime silencer, autotrack enable, …).
Generic on/off switch cap for accessory children (siren, floodlight, spotlight, PIR toggle, chime silencer, autotrack enable, …). The cap owns ONLY the boolean state — driver-specific settings (brightness, sensitivity, schedule, duration) live on the device's own getSettingsUISchema() surface.
At a glance
| Capability | switch |
| Provided by | The device's own driver provides it: each device registers its own provider. |
| Active providers per device | one |
| Device types | switch, siren, light, fan |
| Source | packages/types/src/capabilities/switch.cap.ts |
Methods
Every method takes the device id (deviceId) to address the device; the input tables below list the other fields.
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
setState | mutation | yes | protected |
getOptions | query | no | protected |
powerCycle | mutation | no | protected |
toggle | mutation | no | protected |
setState
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
on | boolean | yes |
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
switch.on | Turn on | on = true |
switch.off | Turn off | on = false |
getOptions
query · optional for a provider
What the switch can do; absent = a plain on/off switch (SWITCH_DEFAULT_OPTIONS).
Input
No fields besides deviceId.
Output
What a switch can do, from its provider (getOptions). A provider that writes no getOptions is a plain on/off switch: the defaults are the old contract.
supportsSetState: false— the switch reports its state but cannot be set (a PoE port seen only through an API key). Its provider refusessetState; these surfaces withdraw on/off once the device ANSWERED this (switchRefusesSetState): the device hero, the automation action picker (offeredWhenonswitch.on/switch.off/switch.toggle), the defaulttoggle, the HomeKit, Alexa and Google exporters, andpower-sourceon a device the switch powers (getStatus().switchSettable,offeredWhenonpowerSource.on/.off,not-settable). A read that failed or is pending changes nothing.supportsPowerCycle: true— the device behind the switch can cut and restore its own output in one native call (a PoE port's power cycle). It has no control of its own: a linkedpower-source.forceRestartuses it instead of off / wait / on.
| Field | Type | Required | Description |
|---|---|---|---|
supportsSetState | boolean | no (default true) | |
supportsPowerCycle | boolean | no (default false) |
powerCycle
mutation · optional for a provider
A native power cycle, declared by getOptions().supportsPowerCycle. No action of its own (no button): power-source.forceRestart on a device this switch powers calls it. Same tier as setState — it is actuation of the same output.
Input
No fields besides deviceId.
Output
Nothing.
toggle
mutation · optional for a provider
Optional on the provider type: the one default is installed at native-cap registration (withDefaultSwitchToggle) for a driver that does not write its own. No effect — the outcome is the inverse of a state this action does not name, so a scheduler cannot hold it.
Input
No fields besides deviceId.
Output
Nothing.
Actions (offered in automations and on device cards)
| Action | Label | Sets |
|---|---|---|
switch.toggle | Toggle |
Runtime state
The state Dominevo keeps for each device with this capability, readable without calling the provider.
Runtime-state slice — the last applied on/off state, mirrored by the kernel. Read via device.state.switch.value; UI toggles do not need to re-query the provider after a setState mutation.
| Field | Type | Required | Description |
|---|---|---|---|
on | boolean | null | yes | null = the device has never reported its state (a measurement that has not happened is unknown, never false). |
lastChangedAt | number | yes | Ms epoch of the last state change. Useful for UI "X minutes ago". |
Events
onStateChanged
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
on | boolean | null | yes | |
lastChangedAt | number | yes |