ReferenceHTTP API
switch
The switch router: 5 methods of the switch capability, with tier, scope, input and output.
Capability switch · scope device · mode singleton · source packages/types/src/capabilities/switch.cap.ts:57.
Every method is called at /trpc/switch.<method> — queries with GET, mutations with POST. See How to call and Authorization. Device methods take deviceId in their input.
| Method | Kind | Tier | Token scope | Viewer |
|---|---|---|---|---|
getStatus | query | protected | view | yes |
setState | mutation | protected | create | yes |
getOptions | query | protected | view | yes |
powerCycle | mutation | protected | create | yes |
toggle | mutation | protected | create | yes |
switch.getStatus
- Kind: query —
GET /trpc/switch.getStatus(added by the framework) - Tier: protected — any signed-in principal whose scopes cover the method
- Token scope:
viewon capabilityswitch, or categorydevice, or a device grant coveringdeviceId - Viewer: yes
- Try it: open
/system/api-explorer?method=switch.getStatuson your hub
Input
{ deviceId: number }Output
SwitchStatusSchemaShapes: SwitchStatusSchema
switch.setState
- Kind: mutation —
POST /trpc/switch.setState - Tier: protected — any signed-in principal whose scopes cover the method
- Token scope:
createon capabilityswitch, or categorydevice, or a device grant coveringdeviceId - Viewer: yes
- Try it: open
/system/api-explorer?method=switch.setStateon your hub
Input
{ deviceId: number; on: boolean }Output
voidswitch.getOptions
- Kind: query —
GET /trpc/switch.getOptions - Tier: protected — any signed-in principal whose scopes cover the method
- Token scope:
viewon capabilityswitch, or categorydevice, or a device grant coveringdeviceId - Viewer: yes
- Try it: open
/system/api-explorer?method=switch.getOptionson your hub
Input
{ deviceId: number }Output
SwitchOptionsSchemaShapes: SwitchOptionsSchema
switch.powerCycle
- Kind: mutation —
POST /trpc/switch.powerCycle - Tier: protected — any signed-in principal whose scopes cover the method
- Token scope:
createon capabilityswitch, or categorydevice, or a device grant coveringdeviceId - Viewer: yes
- Try it: open
/system/api-explorer?method=switch.powerCycleon your hub
Input
{ deviceId: number }Output
voidswitch.toggle
- Kind: mutation —
POST /trpc/switch.toggle - Tier: protected — any signed-in principal whose scopes cover the method
- Token scope:
createon capabilityswitch, or categorydevice, or a device grant coveringdeviceId - Viewer: yes
- Try it: open
/system/api-explorer?method=switch.toggleon your hub
Input
{ deviceId: number }Output
void