Skip to content

RGB Channels color formats

Wojciech Frącz edited this page Jun 24, 2019 · 10 revisions

API accepts the following formats of giving color value for an RGB channel.

  1. RGB as an integer in color parameter and an optional color_brightness parameter. The color must be between 1 and 0xFFFFFF (16777215) value. If color_brightness is ommitted, the color_brightness value from current state will be used.
  2. RGB in hex format in color parameter and an optional color_brightness parameter. All other rules from the point above apply.
  3. Hue value as an integer in hue parameter with an optional color_brightness parameter. The hue value must be in 0-359 range.
  4. RGB as an objec in rgb parameter. It must contain red, green and blue keys that contain values in 0-255 range.
  5. HSV as an object in hsv parameter. It must contain hue key with value in 0-359 range and saturation and value keys with values in 0-100 range.
  6. Setting random color with random string passed in color parameter, with an optional color_brightness parameter.

You may use only one color format in a single request. Fail to do so will result in an API error.

Example requests

The table below shows the valid requests you may send to the API and the resulting color values that are sent to the IO Device. Please notice, that the device always receives only color and color_brightness values, regardless of the format you used during the execution SET_RGBW_PARAMETERS channel action.

API Request IO Device receives
{"color": "0xFF0000"} {"color": "0xFF0000", "color_brightness": <<same as before>>}
{"color": 16711680} {"color": "0xFF0000", "color_brightness": <<same as before>>}
{"rgb": {"red": 255, "green": 0, "blue": 0}} {"color": "0xFF0000", "color_brightness": 100}
{"color": "0xAA0000"} {"color": "0xAA0000", "color_brightness": <<same as before>>}
{"color": "0xAA0000", "color_brightness": 67} {"color": "0xAA0000", "color_brightness": 67}
{"color": "0xFF0000", "color_brightness": 67} {"color": "0xFF0000", "color_brightness": 67}
{"rgb": {"red": 170, "green": 0, "blue": 0}} {"color": "0xFF0000", "color_brightness": 67}
{"hue": 0} {"color": "0xFF0000", "color_brightness": <<same as before>>}
{"hue": 0, "color_brightness": 67} {"color": "0xFF0000", "color_brightness": 67}
{"hsv": {"hue": 0, "saturation": 100, "value": 100}} {"color": "0xFF0000", "color_brightness": 100}
{"hsv": {"hue": 0, "saturation": 100, "value": 67}} {"color": "0xFF0000", "color_brightness": 67}
{"hsv": {"hue": 139, "saturation": 90, "value": 82}} {"color": "0x15D151", "color_brightness": 82}
{"color": "random"} {"color": "0x87CEFA", "color_brightness": <<same as before>>} (example)
{"color": "random", "color_brightness": 67} {"color": "0x87CEFA", "color_brightness": 67} (example)