HSBType::fromRGB with variables

I having some problems with the following code, I like to feed a variable into my color light, but i simply can’t make it work.
If I change the line with the variable to only number it works (e.g. var HSBType hsb = HSBType::fromRGB(100,50,100) )

var Number CurrentIntColor = All_Dimmer_dummy.state
logInfo("rules", "Current CurrentIntColor "+CurrentIntColor) 
logInfo("state", "Cube new angel "+mihome_sensor_cube_158d0001135c14_rotationAngle.state) 

//need to have a variable witht the state
var Number Angel = mihome_sensor_cube_158d0001135c14_rotationAngle.state

var Number NewIntColor
NewIntColor = CurrentIntColor + Angel

//set limits
if (NewIntColor > 255) { NewIntColor = 255 }
if (NewIntColor < 0) { NewIntColor = 0 }

logInfo("state", "NewIntColor "+NewIntColor) 


var HSBType hsb  = HSBType::fromRGB(NewIntColor,50,100)

sendCommand(Vindue_Dimmer,hsb)
NewIntColor.intValue
1 Like

I have a follow up to this, I have the rule:

rule "Deck Lights Follow Fence Lights From RGB direct"
when
    Item DIRECTrgbvalues changed
then
    if(RGBAll_Deck_Follow_Fence.state == ON) {
    	
        logInfo("Deck Lights", "Received RGB: " + DIRECTrgbvalues.state)
        
        var String httpRGB = DIRECTrgbvalues.state.toString()
        var String[] parts =  httpRGB.split(",")

        val red = Integer::parseInt(parts.get(0))
        val green = Integer::parseInt(parts.get(1))
        val blue = Integer::parseInt(parts.get(2))
        
        logInfo("Deck Lights", "R:" + red + " G:" + green + " B:" + blue)

        var HSBType hsb = HSBType::fromRGB(red, green, blue)

		logInfo("Deck Lights", "hsb.red: " + hsb.red + " hsb.green " + hsb.green + " hsb.blue " + hsb.blue + " sending hsb:" + hsb.toString)
        sendCommand(RGBW_Deck, hsb)

    }
end

Which receives a string via mqtt (from my fence lights), and sets the deck lights to match (via zwave).

This all works fine until you turn the lights on to full white (rgb 255,255,255), this translates to (rgb 100,100,100) HSB 0,0,100 and is apparently OFF as the deck lights go off.

does anyone know why this is? hue 0 should be red, and saturation 0 is white.

What are the limits for HSBType? (I was thinking 0-360, 0-100, 0-100) but maybe it’s 0-359, 0-99 or something.

Any suggestions on how to make black = white? is this a bug in the HSBType?

Thanks.

Just a quick follow up,

It’s the saturation. Apparently saturation 0 is black (off) - I’m sure it should be white though. Also brightness has no effect on the colour setting (ie brightness does not appear to work).

Here is the modified rule that works:

rule "Deck Lights Follow Fence Lights From RGB direct"
when
    Item DIRECTrgbvalues changed
then
    if(RGBAll_Deck_Follow_Fence.state == ON) {
    	
        logInfo("Deck Lights", "Received RGB: " + DIRECTrgbvalues.state)
        
        var String httpRGB = DIRECTrgbvalues.state.toString()
        var String[] parts =  httpRGB.split(",")

        val red = Integer::parseInt(parts.get(0))
        val green = Integer::parseInt(parts.get(1))
        val blue = Integer::parseInt(parts.get(2))
        
        logInfo("Deck Lights", "R:" + red + " G:" + green + " B:" + blue)

        var HSBType hsb = HSBType::fromRGB(red, green, blue)

		logInfo("Deck Lights", "hsb.red: " + hsb.red + " hsb.green " + hsb.green + " hsb.blue " + hsb.blue + " sending hsb:" + hsb.toString)
        if (red == 255 && green == 255 && blue == 255)
            sendCommand(RGBW_Deck, new HSBType("0,1,100"))
        else
            sendCommand(RGBW_Deck, hsb)

    }
end