openhab hyperion rules
cat boblight.rules
var HSBType hsbValue
var String red
var String green
var String blue
var String hexValue
rule “lsBoblight”
when
Item lsBoblight received command
then
{
Boblight.sendCommand(switch receivedCommand {
case 0 : “0,100,1”
case 1 : “0,0,100”
case 2 : “0,100,100”
case 3 : “60,100,100”
case 4 : “120,100,100”
case 5 : “120,100,50”
case 6 : “180,100,100”
case 7 : “240,100,100”
case 8 : “300,100,100”
case 9 : “0,0,0”
default : “0,100,1”
})
}
end
rule “Boblight”
when
Item Boblight changed
then
executeCommandLine(‘/usr/bin/hyperion-remote@@–clearall’)
hsbValue = Boblight.state as HSBType
red = Integer::toHexString(hsbValue.red.intValue)
green = Integer::toHexString(hsbValue.green.intValue)
blue = Integer::toHexString(hsbValue.blue.intValue)
hexValue = (“00″+red).substring(red.length()) + (“00″+green).substring(green.length()) + (“00″+blue).substring(blue.length());
if (hexValue.equals(“010000”)) {
executeCommandLine(‘/usr/bin/hyperion-remote@@-c@@000000’)
lsBoblight.sendCommand(0)
} else if (!hexValue.equals(“000000”)) {
executeCommandLine(‘/usr/bin/hyperion-remote@@-c@@’ + hexValue)
} else {
lsBoblight.sendCommand(9)
}
end