Scene script for continuous color change

Please note - Uncorrected machine translation

This English version of the following text is currently 100% machine translated. In case of ambiguity, please refer to the German version (which in this case is the original written by hand).

With the following scenescripts a persistent scene of a color luminaire can be made a dynamic scene, so that after calling the scene the color changes continuously.

This works with all types of color lights, be it DALI (grouped RGB(W) single dimmers or DT-8 color lights), hue at P44-DSB-DEH/D and P44-LC-DE, RGB and RGBW SmartLED chains, DMX lights and PWM outputs to P44-xx-X, and of course color lights created as Custom Device.

The first example makes the color move through the color wheel by rotating the "hue" channel 15 degrees every 10 seconds (360 degrees = full color wheel, so one rotation in 360/15*10 = 240 seconds = 4 min).

The second example makes the color oscillate between two hue values.

How to enter a scene script?

Detailed instructions on how to create a scene script on a P44-DSB or P44-LC device are available here.

Example 1: Whole colorwheel.

The following script can be copied 1:1 and entered into the "Script to execute..." field in the sceneedit dialog can be entered, but of course it can also be adjusted as needed.

// Slow color change through the whole hue color circle (0..360 degrees)
var d = 10 // Number of seconds for a 15 degree step
// Adjust current color value to an integer multiple of 15
// (Not absolutely necessary, but recommended depending on the luminaire if the
// pure red, green, blue color points should be achieved)
output.channel('hue',round(output.channel('hue'),15));
// From here on the script should run endlessly in the background, but nevertheless
// the scene call should be completed. Therefore the running color change
// is moved to the background with `concurrent`.
concurrent {
  // Endless until another scene is called
  while(true) {
    // increase hue (angle in color circle) by 15 degrees (goes back to 0 at 360)
    // With fade time = d (see above)
    output.dimchannel('hue',15, d)
    // Apply channels to hardware
    output.applychannels()
    // Wait for fade time until the next 15 degree step is made
    delay(d)
  }
}

Example 2: Switching colors back and forth between two values.

In this variant, two hue color values can be specified in the variables from and to, between which the color will then slowly change back and forth. With the variables steps and d the number of intermediate steps and the step duration (not too short, see notes) are determined.

The following script can be copied 1:1 and entered into the "Script to execute..." field in the sceneedit dialog can be entered, but of course it can also be adjusted as needed.

// Slow color change between hue=from and hur=to
var from = 30 // orange
var to = 140 // green
var steps = 6 // number of steps
var d = 5 // number of seconds per step - 8-ung, do not set too short (>1 sec)
// From here on the script should run endlessly in the background, but nevertheless
// the scene call should be finished. Therefore the running color change
// is moved to the background with `concurrent`.
concurrent {
  var hue = from
  var step = (to-from)/steps
  // Endless, until another scene is called
  while(true) {
    var i = 0
    // Forward from->to
    while (i<steps) {
      output.channel('hue',from+i*step, d) // Set new hue value with fade time
      output.applychannels() // Apply channels to hardware
      delay(d) // Wait for fade time
      i = i+1
    }
    // backwards to->from
    while (i>0) {
      output.channel('hue',from+i*step, d) // Set new hue value with crossfade time
      output.applychannels() // Apply channels to hardware
      delay(d) // Wait for fade time
      i = i-1
    }
  }
}

Notes

More info