{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","results":{"codes":[]},"params":[]},"next":{"description":"","pages":[]},"title":"Switch Messages","type":"basic","slug":"switch-messages","excerpt":"","body":"The switch messages are for controlling features specific to the [LIFX Switch](doc:the-lifx-switch). The public API only contains messages for turning \"relays\" on and off and more messages will be added in the future.\n\nA LIFX switch has a number of buttons that may either modify a physical \"relay\" attached to a \"dumb\" light, or make a request to the LIFX cloud to modify a light.\n\nThe switch has both inputs (the physical buttons on the device) and outputs (the electrical relays). The following messages allow you to inspect and set the power level of those electrical relays.\n\n### GetRelayPower - 816\n\nGet the power state of a relay on a switch device. Causes the device to transmit a [StateRealyPower](#section-staterelaypower-818) message.\n\n| Field | Type | Description |\n|-------|------|------|\n| relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 |\n\n### SetRelayPower - 817\n\nSet the power state of a relay on a switch device. Current models of the LIFX switch do not have dimming capability, so the two valid values are `0` for off and `65535` for on. Causes the device to transmit a [StateRealyPower](#section-staterelaypower-818) message.\n\n| Field | Type | Description |\n|-------|------|------|\n| relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 |\n| level | unsigned 16-bit integer | The new value of the relay |\n\n### StateRelayPower - 818\n\nResponse to [GetRelayPower](#section-setrelaypower-816) and [SetRelayPower](#section-setrelaypower-817) message.\n\nCurrent models of the LIFX switch do not have dimming capability, so the two valid values are `0` for off and `65535` for on. \n\n| Field | Type | Description |\n|-------|------|------|\n| relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 |\n| level | unsigned 16-bit integer | The new value of the relay |","updates":[],"order":5,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5fa4a22d288963002d4e0a88","createdAt":"2020-11-06T01:09:01.379Z","user":"57749b725b96cf0e00558ea6","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Protocol Messages","slug":"message-types","order":3,"from_sync":false,"reference":false,"_id":"57fdb17c4defec0e0064228e","project":"5581248904ae5b0d0026289a","__v":0,"version":"57fdb17c4defec0e0064228b","createdAt":"2015-06-18T03:15:52.144Z"},"version":{"version":"2.0","version_clean":"2.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["57fdb17c4defec0e0064228c","57fdb17c4defec0e0064228d","57fdb17c4defec0e0064228e","57fdb520bcc07b0e00d1ef41"],"_id":"57fdb17c4defec0e0064228b","project":"5581248904ae5b0d0026289a","__v":2,"createdAt":"2016-10-12T03:43:56.009Z","releaseDate":"2016-10-12T03:43:56.009Z"},"project":"5581248904ae5b0d0026289a","__v":0,"parentDoc":null}
The switch messages are for controlling features specific to the [LIFX Switch](doc:the-lifx-switch). The public API only contains messages for turning "relays" on and off and more messages will be added in the future. A LIFX switch has a number of buttons that may either modify a physical "relay" attached to a "dumb" light, or make a request to the LIFX cloud to modify a light. The switch has both inputs (the physical buttons on the device) and outputs (the electrical relays). The following messages allow you to inspect and set the power level of those electrical relays. ### GetRelayPower - 816 Get the power state of a relay on a switch device. Causes the device to transmit a [StateRealyPower](#section-staterelaypower-818) message. | Field | Type | Description | |-------|------|------| | relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 | ### SetRelayPower - 817 Set the power state of a relay on a switch device. Current models of the LIFX switch do not have dimming capability, so the two valid values are `0` for off and `65535` for on. Causes the device to transmit a [StateRealyPower](#section-staterelaypower-818) message. | Field | Type | Description | |-------|------|------| | relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 | | level | unsigned 16-bit integer | The new value of the relay | ### StateRelayPower - 818 Response to [GetRelayPower](#section-setrelaypower-816) and [SetRelayPower](#section-setrelaypower-817) message. Current models of the LIFX switch do not have dimming capability, so the two valid values are `0` for off and `65535` for on. | Field | Type | Description | |-------|------|------| | relay_index | unsigned 8-bit integer | The relay on the switch starting from 0 | | level | unsigned 16-bit integer | The new value of the relay |