1. Home
  2. Scripting
  3. RGBW loop controller

Scripting

RGBW loop controller

Run a colour loop entirely on the device, edited from its own web page.

Updated August 2026

What this is

A colour loop is easy to describe and awkward to build: a sequence of colours, each held for a moment, fading into the next, repeating. Doing it from the cloud means a command every few seconds; doing it from a script usually means editing code to change a colour.

This does it on the device. The script carries fourteen presets, runs them locally, and serves its own web interface where you can pick a preset, adjust brightness and speed, build new ones in an editor, and decide what each physical input does.

Nothing else is involved. No app, no cloud account, no Home Assistant — the device does the whole thing and keeps doing it when the network is gone.

The web interface lives at http://<device-ip>/script/<script-id>/ui — and the script renames the output to that address, so it appears in the app as a reminder of where to find it.

Which script for which device

Three versions, ported from one another. Use the one that matches the hardware:

Device Script Device profile
Shelly Pro RGBWW PM rgbw-loop-pro.js RGB and lights x 2
Shelly Plus RGBW PM rgbw-loop-plus.js RGBW
Shelly RGBCCT Bulb Gen3 rgbw-loop-bulb.js

The three filenames are links. Each opens the script in your browser, where you can select all and copy — they are 1 579 lines between them, which is why they are not printed on this page. Everything you actually edit is reachable from the web interface instead.

The Pro version is the original. The Plus version is a port of it, and the bulb version is ported further — with the white channel replaced by colour temperature, since a CCT bulb has no separate white to drive.

Set the device profile before installing the script. Changing it afterwards means the outputs no longer mean what the script expects. See LED strip control for what the profiles do.

Tested on firmware 1.7.5.

Installing

Create a script on the device and paste in the version for your hardware, from the links above. See how to add a script.

Auto-start is enabled by the script itself — you do not have to set it.

When it starts, the console prints the web interface address. Open it in a browser on the same network.

The web interface

Three pages, at http://<device-ip>/script/<script-id>/ui.

Main — manual colour, and the loop. Pick a preset, adjust brightness and speed while it runs.

Input settings — what each physical input press does. Four actions are available:

  • Toggle — switches between the chosen preset and off
  • Preset — always starts the chosen preset
  • Cycle — steps through a selection of presets, one per press
  • Dim — long press only; raises or lowers brightness while held

Editor — edit the built-in presets, create new ones, or paste one in as text. Everything you create is stored in the device’s KVS, so it survives a reboot and a firmware update.

Presets and the format

Fourteen come built in: Rainbow, Candle, Ocean, Sunset, Party, Nordic, and eight breathing presets — white, red, green, blue, yellow, purple, and an RGB cycle.

A preset is a plain string. Each step is six numbers, and steps are separated by a pipe:

red,green,blue,white,brightness,seconds

So the Candle preset is three steps:

255,100,10,20,70,1.4|255,80,5,10,55,1.3|255,120,20,25,80,1.5

Red, green, blue and white run 0–255; brightness is a percentage; the last number is how long that step lasts, in seconds. On the bulb version the fourth number is colour temperature in kelvin rather than a white channel.

That format is why the editor has a code view. A preset is a line of text you can write, copy, paste and share — which is a great deal easier than building one click by click.

Short steps are what causes the crashes in the warning above. A preset with half-second steps is already working the device hard; the speed control multiplies that.

Input actions

The point of the input settings page is that a physical switch can drive the loop without anything else involved.

A useful pattern on a single button: Toggle on short press for on and off, Dim on long press for brightness. That gives an ordinary switch the behaviour people expect from a dimmer, with a colour loop behind it.

With several inputs, Cycle on one of them lets the customer step through a shortlist of presets without opening anything.

Virtual buttons

On the Pro RGBWW and the RGBCCT bulb, each preset can be bound to a virtual button — ids 201 to 208. Pressing the button in the app starts that preset. Id 200 is reserved for off.

This is what puts the loops on the phone. It also makes them available to scenes: a scene’s Do action can press a virtual button, so a preset can be started by a schedule, a sensor, or an away state. See scenes and automations.

The Plus RGBW does not have virtual components, so this section does not apply to it.

Tips & best practices

  • Give the device to the loop alone. It is the one script that genuinely needs the whole device.
  • Build presets in the code view. Six numbers per step is faster to type than to click, and a preset that works can be pasted into the next device.
  • Slow steps look better than fast ones on almost everything except a party. Candle and Ocean run at over a second per step for a reason.
  • Stop the loop before changing settings, especially on a fast preset.
  • Note the script id. The web interface address contains it, and it changes if the script is deleted and recreated.