RGB Channels color formats - SUPLA/supla-cloud GitHub Wiki
API accepts the following formats of giving color value for an RGB channel.
- RGB as an integer in
colorparameter and an optionalcolor_brightnessparameter. Thecolormust be between 1 and0xFFFFFF(16777215) value. Ifcolor_brightnessis ommitted, thecolor_brightnessvalue from current state will be used. - RGB in hex format in
colorparameter and an optionalcolor_brightnessparameter. All other rules from the point above apply. - Hue value as an integer in
hueparameter with an optionalcolor_brightnessparameter. Thehuevalue must be in 0-359 range. - RGB as an objec in
rgbparameter. It must containred,greenandbluekeys that contain values in 0-255 range. - HSV as an object in
hsvparameter. It must containhuekey with value in 0-359 range andsaturationandvaluekeys with values in 0-100 range. - Setting random color with
randomstring passed incolorparameter, with an optionalcolor_brightnessparameter.
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) |