{"_id":"57fdb17c4defec0e00642294","category":{"_id":"57fdb17c4defec0e0064228e","project":"5581248904ae5b0d0026289a","__v":0,"version":"57fdb17c4defec0e0064228b","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-06-18T03:15:52.144Z","from_sync":false,"order":3,"slug":"message-types","title":"Protocol Messages"},"parentDoc":null,"user":"557e2561eb75d80d00af3dab","version":{"_id":"57fdb17c4defec0e0064228b","project":"5581248904ae5b0d0026289a","__v":2,"createdAt":"2016-10-12T03:43:56.009Z","releaseDate":"2016-10-12T03:43:56.009Z","categories":["57fdb17c4defec0e0064228c","57fdb17c4defec0e0064228d","57fdb17c4defec0e0064228e","57fdb520bcc07b0e00d1ef41"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2.0"},"__v":1,"project":"5581248904ae5b0d0026289a","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-06-18T03:19:08.438Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Light messages control and acquire the state of a specific type of device, such as a lightbulb.  The state is comprised of the [label](doc:device-messages#section-label), [power level](doc:device-messages#section-power-level) and [color](#section-hsbk).\n\nThere are a duplicate set of __device__ power related messages, [Device::GetPower](doc:device-messages#section-getpower-20), [Device::StatePower](doc:device-messages#section-statepower-22) and [Device::SetPower](doc:device-messages#section-setpower-21), which are extended for lights by adding a _duration_ field to [Light::SetPower](#section-setpower-117).\n\nThe [Protocol header](doc:header-description#protocol-header) _message type_ field value (decimal) appears after each message name in this document. Each section below describes the _payload_ that is appended to the [message header](doc:header-description). Some messages do not require a payload.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Message Field Data Types\"\n}\n[/block]\n### HSBK\n\nHSBK is used to represent the _color_ and _color_ temperature of a light.\n\nThe _color_ is represented as an HSB ([Hue, Saturation, Brightness](http://en.wikipedia.org/wiki/HSL_and_HSV)) value.\n\nThe _color temperature_ is represented in K ([Kelvin](http://en.wikipedia.org/wiki/Color_temperature)) and is used to adjust the warmness / coolness of a white light, which is most obvious when saturation is close zero.\n\n* Hue: range 0 to 65535\n* Saturation: range 0 to 65535\n* Brightness: range 0 to 65535\n* Kelvin: range 2500° (warm) to 9000° (cool)\n\n| Field | Type |\n|-------|------|\n| hue | unsigned 16-bit integer |\n| saturation | unsigned 16-bit integer |\n| brightness | unsigned 16-bit integer |\n| kelvin | unsigned 16-bit integer |\n\nFor user interface purposes, the hue is typically scaled to between 0° and 360°. Saturation and brightness are typically scaled to between 0% and 100%.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Light Messages\"\n}\n[/block]\n### Get - 101\n\nSent by a client to obtain the light state. No payload required. Causes the device to transmit a [State](#section-state-107) message.\n\n### SetColor - 102\n\nSent by a client to change the light state.\n\n| Field | Type |\n|-------|------|\n| reserved | unsigned 8-bit integer |\n| color | HSBK |\n| duration | unsigned 32-bit integer |\n\nThe _duration_ is the color transition time in milliseconds.\n\nIf the [Frame Address](doc:header-description#frame-address) *res\\_required* field is set to one (1) then the device will transmit a [State](#section-state-107) message.\n\n### SetWaveform - 103\n\nApply an effect to the bulb.\n\nThis message will be replied to with a State message.\n\n| Field | Type | Purpose |\n|-------|------|---------|\n| reserved | unsigned 8-bit integer | |\n| transient | 8-bit integer as 0 or 1 | Color does not persist. |\n| color | Hsbk | Light end color. |\n| period | unsigned 32-bit integer | Duration of a cycle in milliseconds. |\n| cycles | 32-bit float | Number of cycles. |\n| skew_ratio | signed 16-bit integer | Waveform Skew, [-32768, 32767] scaled to [0, 1]. |\n| waveform | unsigned 8-bit integer | Waveform to use for transition. |\n\nSee [Waveforms](doc:waveforms) for more information.\n\n### SetWaveformOptional - 119\n\nOptionally set effect parameters. Same as SetWaveform but allows some parameters to be set from the current value on device.\n\nThis message will be replied to with a State message.\n\n| Field | Type |\n|-------|------|\n| reserved | unsigned 8-bit integer |\n| transient | boolean |\n| color | Hsbk |\n| period | unsigned 32-bit integer |\n| cycles | 32-bit float |\n| skew_ratio | signed 16-bit integer |\n| waveform | unsigned 8-bit integer |\n| set_hue | 8-bit integer as 0 or 1 |\n| set_saturation | 8-bit integer as 0 or 1 |\n| set_brightness | 8-bit integer as 0 or 1 |\n| set_kelvin | 8-bit integer as 0 or 1 |\n\nSee [Waveforms](doc:waveforms) for more information.\n\n### State - 107\n\nSent by a device to provide the current light state.\n\n| Field | Type |\n|-------|------|\n| color | HSBK |\n| reserved | signed 16-bit integer |\n| power | unsigned 16-bit integer |\n| label | string, size: 32 bytes |\n| reserved | unsigned 64-bit integer |\n\nSee [color](#section-hsbk), [label](doc:device-messages#section-label) and [power level](doc:device-messages#section-power-level).\n\n### GetPower - 116\n\nSent by a client to obtain the [power level](doc:device-messages#section-power-level). No payload required. Causes the device to transmit a [StatePower](#section-statepower-118) message.\n\n### SetPower - 117\n\nSent by a client to change the light [power level](doc:device-messages#section-power-level).\n\n| Field | Type |\n|-------|------|\n| level | unsigned 16-bit integer |\n| duration | unsigned 32-bit integer |\n\nThe [power level](doc:device-messages#section-power-level) must be either 0 or 65535.\n\nThe _duration_ is the _power level_ transition time in milliseconds.\n\nIf the [Frame Address](doc:header-description#frame-address) *res\\_required* field is set to one (1) then the device will transmit a [StatePower](#section-statepower-118) message.\n\n### StatePower - 118\n\nSent by a device to provide the current [power level](doc:device-messages#section-power-level).\n\n| Field | Type |\n|-------|------|\n| level | unsigned 16-bit integer |\n\n### GetInfrared - 120\n\nGets the current maximum power level of the Infrared channel. If the [Frame Address](doc:header-description#frame-address) *res_required* field is set to one (1) then the device will transmit a [StateInfrared](#section-stateinfrared-121) message.\n\nNo payload is required\n\n### StateInfrared - 121\n\nThis message is returned from a [GetInfrared](#section-getinfrared-120) message. It indicates the current maximum setting for the infrared channel.\n\n| Field | Type |\n|-------|------|\n| brightness | unsigned 16-bit integer |\n\n### SetInfrared - 122\n\nSend this message to alter the current maximum brightness for the infrared channel.\n\nIf the [Frame Address](doc:header-description#frame-address) *res_required* field is set to one (1) then the device will transmit a [StateInfrared](#section-stateinfrared-121) message.\n\n| Field | Type |\n|-------|------|\n| brightness | unsigned 16-bit integer |","excerpt":"","slug":"light-messages","type":"basic","title":"Light Messages"}
Light messages control and acquire the state of a specific type of device, such as a lightbulb. The state is comprised of the [label](doc:device-messages#section-label), [power level](doc:device-messages#section-power-level) and [color](#section-hsbk). There are a duplicate set of __device__ power related messages, [Device::GetPower](doc:device-messages#section-getpower-20), [Device::StatePower](doc:device-messages#section-statepower-22) and [Device::SetPower](doc:device-messages#section-setpower-21), which are extended for lights by adding a _duration_ field to [Light::SetPower](#section-setpower-117). The [Protocol header](doc:header-description#protocol-header) _message type_ field value (decimal) appears after each message name in this document. Each section below describes the _payload_ that is appended to the [message header](doc:header-description). Some messages do not require a payload. [block:api-header] { "type": "basic", "title": "Message Field Data Types" } [/block] ### HSBK HSBK is used to represent the _color_ and _color_ temperature of a light. The _color_ is represented as an HSB ([Hue, Saturation, Brightness](http://en.wikipedia.org/wiki/HSL_and_HSV)) value. The _color temperature_ is represented in K ([Kelvin](http://en.wikipedia.org/wiki/Color_temperature)) and is used to adjust the warmness / coolness of a white light, which is most obvious when saturation is close zero. * Hue: range 0 to 65535 * Saturation: range 0 to 65535 * Brightness: range 0 to 65535 * Kelvin: range 2500° (warm) to 9000° (cool) | Field | Type | |-------|------| | hue | unsigned 16-bit integer | | saturation | unsigned 16-bit integer | | brightness | unsigned 16-bit integer | | kelvin | unsigned 16-bit integer | For user interface purposes, the hue is typically scaled to between 0° and 360°. Saturation and brightness are typically scaled to between 0% and 100%. [block:api-header] { "type": "basic", "title": "Light Messages" } [/block] ### Get - 101 Sent by a client to obtain the light state. No payload required. Causes the device to transmit a [State](#section-state-107) message. ### SetColor - 102 Sent by a client to change the light state. | Field | Type | |-------|------| | reserved | unsigned 8-bit integer | | color | HSBK | | duration | unsigned 32-bit integer | The _duration_ is the color transition time in milliseconds. If the [Frame Address](doc:header-description#frame-address) *res\_required* field is set to one (1) then the device will transmit a [State](#section-state-107) message. ### SetWaveform - 103 Apply an effect to the bulb. This message will be replied to with a State message. | Field | Type | Purpose | |-------|------|---------| | reserved | unsigned 8-bit integer | | | transient | 8-bit integer as 0 or 1 | Color does not persist. | | color | Hsbk | Light end color. | | period | unsigned 32-bit integer | Duration of a cycle in milliseconds. | | cycles | 32-bit float | Number of cycles. | | skew_ratio | signed 16-bit integer | Waveform Skew, [-32768, 32767] scaled to [0, 1]. | | waveform | unsigned 8-bit integer | Waveform to use for transition. | See [Waveforms](doc:waveforms) for more information. ### SetWaveformOptional - 119 Optionally set effect parameters. Same as SetWaveform but allows some parameters to be set from the current value on device. This message will be replied to with a State message. | Field | Type | |-------|------| | reserved | unsigned 8-bit integer | | transient | boolean | | color | Hsbk | | period | unsigned 32-bit integer | | cycles | 32-bit float | | skew_ratio | signed 16-bit integer | | waveform | unsigned 8-bit integer | | set_hue | 8-bit integer as 0 or 1 | | set_saturation | 8-bit integer as 0 or 1 | | set_brightness | 8-bit integer as 0 or 1 | | set_kelvin | 8-bit integer as 0 or 1 | See [Waveforms](doc:waveforms) for more information. ### State - 107 Sent by a device to provide the current light state. | Field | Type | |-------|------| | color | HSBK | | reserved | signed 16-bit integer | | power | unsigned 16-bit integer | | label | string, size: 32 bytes | | reserved | unsigned 64-bit integer | See [color](#section-hsbk), [label](doc:device-messages#section-label) and [power level](doc:device-messages#section-power-level). ### GetPower - 116 Sent by a client to obtain the [power level](doc:device-messages#section-power-level). No payload required. Causes the device to transmit a [StatePower](#section-statepower-118) message. ### SetPower - 117 Sent by a client to change the light [power level](doc:device-messages#section-power-level). | Field | Type | |-------|------| | level | unsigned 16-bit integer | | duration | unsigned 32-bit integer | The [power level](doc:device-messages#section-power-level) must be either 0 or 65535. The _duration_ is the _power level_ transition time in milliseconds. If the [Frame Address](doc:header-description#frame-address) *res\_required* field is set to one (1) then the device will transmit a [StatePower](#section-statepower-118) message. ### StatePower - 118 Sent by a device to provide the current [power level](doc:device-messages#section-power-level). | Field | Type | |-------|------| | level | unsigned 16-bit integer | ### GetInfrared - 120 Gets the current maximum power level of the Infrared channel. If the [Frame Address](doc:header-description#frame-address) *res_required* field is set to one (1) then the device will transmit a [StateInfrared](#section-stateinfrared-121) message. No payload is required ### StateInfrared - 121 This message is returned from a [GetInfrared](#section-getinfrared-120) message. It indicates the current maximum setting for the infrared channel. | Field | Type | |-------|------| | brightness | unsigned 16-bit integer | ### SetInfrared - 122 Send this message to alter the current maximum brightness for the infrared channel. If the [Frame Address](doc:header-description#frame-address) *res_required* field is set to one (1) then the device will transmit a [StateInfrared](#section-stateinfrared-121) message. | Field | Type | |-------|------| | brightness | unsigned 16-bit integer |