Hi OH community,
Can anyone help with syntax on the following rule? This rule is for an inovelli zwave switch and was written by sovapatr on the inovelli message boards. The variable “currentEffect” adjusts the onboard LED on the device to show different visual indicators.
case 3.0: {
var int currentEffect = (BRE_Dimmer_01_LEDStripEffect.state as Number).intValue
var int e = currentEffect.bitwiseAnd(255 << 24) >> 24 //effect 1-5
var int d = currentEffect.bitwiseAnd(255 << 16) >> 16 //duration 0-255
var int b = currentEffect.bitwiseAnd(255 << 8) >> 8 //brightness 1-10
var int c = currentEffect.bitwiseAnd(255) //color 0-255
c = (c + 16) % 255 //Increment color
var hue = c * 360 / 255 //Convert 0-255 to 0-360
var HSBType color = new HSBType(new DecimalType(hue),new PercentType(100),new PercentType(100))
var newEffect = currentEffect.bitwiseAnd(-256).bitwiseOr(c) //replace color
BRE_Dimmer_01_LEDStripEffect.sendCommand(newEffect)
BRE_LightBulb_01_Color.sendCommand(color)
logInfo("Config Button Pressed", "Effect: " + e.toString + ", Duration: " + d.toString + ", Brightness: " + b.toString + ", Color: " + c.toString)
}
It takes the existing 4 bit value, reads the current settings, changes the first bit, and updates the value (color).
I’ve tried various things for this line, but can’t seem to get it to update to the proper value.
var newEffect = currentEffect.bitwiseAnd(-256).bitwiseOr(c) //replace color
I would like to accomplish the same, but change the last bit (effect) instead of the first (color).
Thanks so much!