Control the single-color LED strip within 0-100% using the SLIDER widget

Grenton system allows controlling single-color LED circuit. This article presents a setup to enable controlling the value of a strip using the SLIDER widget in the range of 0-100%.

To display the values as a percentage instead of in the range of 0-255, you need to scale them. Below is an example configuration for the red (R) channel.

  1. Create a user feature of number type (red_value), to which the percentage value of the R channel will be passed.

  2. Create a script (red_value_scr) that will convert the value of the RedValue feature from 0-255 to the 0-100% form:
    CLU->red_value = math.ceil((CLU->LEDRGB->RedValue * 100) / 255)

    Note: The script uses rounding of values to integers. For more information on using the math.ceil function, see the article.

  3. Assign the red_value_scr script to the OnValueChange event of the RGBW LED module.

  4. In the next step, create a script (set_red_value_scr) that will convert the value set with the SLIDER widget (0-100%) to the 0-255 form:
    red_val = (red_val * 255) / 100

    where red_val is a script parameter of number type :

  5. Fill out the SLIDER widget as follows:

where red_switch() is a script responsible for changing the state of 0/255 R channel. An example of a script implementing switch logic is presented in the article

Similarly, you can create a configuration for the remaining channels (G, B, W).