RGB control

I’m trying to get 3 sliders to work with some colored lights.
So far I’ve tried to use another rule and adapt it for my use. It only need to go one way.
So in HABPanel i have 3 sliders with 3 seperate items behind them.

The rule i’m trying to adapt is this:

import org.openhab.core.library.types.*

    var HSBType hsbValue
    var String  redValue
    var String  greenValue
    var String  blueValue

rule "Set RGB value"
        Item Color1RED changed or
        Item Color1GREEN changed or
        Item Color1BLUE changed
        hsbValue = Color1.state as HSBType

        redValue   = hsbValue.red.intValue.toString
        greenValue = hsbValue.green.intValue.toString
        blueValue  = hsbValue.blue.intValue.toString

A little update here.
As far as i can tell this should work as i want:

import org.openhab.core.library.types.*
import java.awt.Color
rule "Set RGB value"
        Item Color1RED changed or
        Item Color1GREEN changed or
        Item Color1BLUE changed
        val color = Color1RED + Color1GREEN + Color1BLUE

        sendCommand(Color1, color)

BUT i get an error (of course):

2020-05-06 14:55:25.569 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set RGB value': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

There’s some confusion going on there.

  • What type of command are you trying to send to this color Item?
  • What value ranges are your three color items offering?


Red = 50
Green = 50
Blue = 50

Then the command RED + GREEN + BLUE would give 150

Unless they are converted to strings (or are strings already)

RED.toString + GREEN.toString + BLUE.toString

Would give 505050

But a HSL value should be

Hue as a ° (0 to 359)
Saturation as a %
Luminescence as a %


RED = 50
GREEN = 50
BLUE = null

Then the maths will result in a null error

Does that help you?


Explanations of the different ways colours can be expressed are explained here


I actually realized, shortly after i posted, that i was way off. But thank you for confirming my madness :smiley:

The thing i want to do is to convert 3 slider values to HSL values that i can send to a color LED.

So the ‘then’ part of my first post is the part i need to focus on. But i can’t find the necessary documentation to make this happen.

Thankfully you’re not the first person to come across this…

Does this help you?

I had a look at it, along with a whole lot of other posts, and i don’t have a DMX bridge at hand (yet?).

So at first i would like to get the basic part done. I’m trying to get this to work: Link

But a follow up on your link. Will i get the ability to expose Zigbee light to a DMX control?

I’ve beaten my head against a wall trying to work that out too.

Which is why I ended up cheating by leveraging the amazing DMX Binding.

Good luck with your hunt for a DSL based solution.

Not exactly.

It’s more about getting a DMX Color Picker to do the heavy lifting of converting the 3 x levels in to a HSL value, then linking the same Item to both the Color Picker of the DMX Color Thing AND the Color channel of your Zigbee Thing.

As I say, it is a cheat and by no means is it a clever or “normal” solution.

But as they say…

If you want a job done quickly, ask a lazy person