WifLED Brightness

OK, I’ve set up a WifiLED “thing” in OpenHab2, and I have tried creating links to items for on/off, color, and brightness. I want to use these bindings to create a HABPanel interface.

I can turn it on and off.
I can change the color.
I cannot change the brightness.

I’ve tried linking the white channel to brightness, then linking white2 channel to brightness, and then linking both white and white2 to brightness. No matter what, when I use a slider to operate on that brightness item, nothing happens.

Also, if the color is changed through another interface (e.g. Amazon Alexa, or the MagicHome app), the HABpanel widget does not change.

Any thoughts?

Thanks,

Bruce

You can send ON/OFF and brightness command to the Color Item linked to the Color channel I believe. The White channels are used to change the color temperature of the bulb, not the brightness.

You do not need to create three different Items linked to different channels. You only need the one Color Item to turn the light ON/OFF, change the brightness, or change the color. You will need separate Items to change the color temp though.

If you want to change the brighness, you need to raise or lower the luminence of the led (the L of HSL)

Ex: sendcommand(279,41,1) low power and sendcommand(279,41,100) max power

Here is the rule that is working for me

rule

rule "rLedBrightness"
when Item Wifiled_1_brightness received command
then 
    logInfo("rLedBrightness", "Wifiled_1_brightness received Command "+receivedCommand)
    var HSBType currentState
    currentState = Wifiled_1_color.state as HSBType
    var DecimalType new_H = currentState.hue
    var PercentType new_S = currentState.saturation
    var PercentType new_B = Wifiled_1_brightness.state
    val HSBType color = new HSBType(new_H, new_S, new_B)
    Wifiled_1_color.sendCommand(color)
end

items

Switch Wifiled_1 "WifiLed 1" (Light) {channel="wifiled:wifiled:1:power"}
Color  Wifiled_1_color "Wifiled1 Couleur" (Light) {channel="wifiled:wifiled:1:color"}
Dimmer Wifiled_1_brightness "Wifiled1 Blanc"   <volume_knob>  

sitemap

sitemap wifiled label="LED Wifi"
{
Switch item=Wifiled_1
Colorpicker item=Wifiled_1_color
Slider item=Wifiled_1_brightness
}

Or just sendCommand(1) and sendCommand(100)

Really … ? :yum:

rule "rLedBrightness"
when Item Wifiled_1_brightness received command
then 
    var PercentType new_B = Wifiled_1_brightness.state
    Wifiled_1_color.sendCommand(new_B)
end

Yep! And if you want to turn it on or off, you can send OnOffType commands to Color Items too.

Wifiled_1_color.sendCommand(OFF)

Furthermore, you can get the state of a Color Item as if it were a Dimmer or a Switch as well…

    if(MyColorItem.getStateAs(OnOffType) == ON) // light is ON

    if(MyColorItem.getStateAs(PercentType) > 50) // light is at a brightness over 50%

Hi there,

i found this while i try to solve the same issue.
this is my rule:

rule "Wifi RGB DDC4B2 Brightness"
when Item WifiRGBDDC4B2brightness received command
then 
    //logInfo("Wifi RGB DDC4B2 Brightness", "WifiRGBDDC4B2brightness received Command "+receivedCommand)
    var HSBType currentState
    currentState = WifiRGBDDC4B2Color.state as HSBType
    var DecimalType new_H = currentState.hue
    var PercentType new_S = currentState.saturation
    var PercentType new_B = WifiRGBDDC4B2brightness.state
    val HSBType color = new HSBType(new_H, new_S, new_B)
    WifiRGBDDC4B2Color.sendCommand(color)
end

But Vscode throws me this:
{
“resource”: “/Volumes/openHAB-conf/rules/wifiRGB-DDC4B2.rules”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “org.eclipse.xtext.xbase.validation.IssueCodes.incompatible_types”,
“severity”: 8,
“message”: “Type mismatch: cannot convert from State to PercentType”,
“startLineNumber”: 26,
“startColumn”: 29,
“endLineNumber”: 26,
“endColumn”: 58
}

And also this:
{
“resource”: “/Volumes/openHAB-conf/rules/wifiRGB-DDC4B2.rules”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “org.eclipse.xtext.xbase.validation.IssueCodes.ambiguous_feature_call”,
“severity”: 8,
“message”: “Ambiguous feature call.\nThe extension methods\n\tsendCommand(Item, Command) in BusEvent and\n\tsendCommand(Item, Number) in BusEvent\nboth match.”,
“startLineNumber”: 28,
“startColumn”: 24,
“endLineNumber”: 28,
“endColumn”: 35
}

But when i save the rule Openhab doesnt throw any error.
And i can change the Brightness with a Slider.

Why is Vscode throw this messages ?

Br Peter

Solved:

rule "Wifi RGB 408867 Brightness"
when Item WifiRGB408867brightness received command
then 
    var PercentType new_B = WifiRGB408867brightness.state as PercentType
    WifiRGB408867Color.sendCommand(new_B.toString)
end