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.
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.
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
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
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.
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