.item:
Color Boblight <colorwheel></colorwheel>
.rules
import org.openhab.core.library.types.*
var HSBType hsbValue
var String red
var String green
var String blue
var String hexValue
rule "Boblight" when Item Boblight changed then
executeCommandLine('/usr/bin/killall@@boblight-constant')
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("000000")) {
logInfo( "FILE", hexValue )
executeCommandLine('/usr/bin/boblight-constant@@-p@@0@@-f@@-s@@172.16.40.132@@' + hexValue) }
end
UPDATE:
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 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"
default : "0,0,0" }) }
end
rule "Boblight" when Item Boblight changed then
executeCommandLine('/usr/bin/killall@@boblight-constant')
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("000000")) {
executeCommandLine('/usr/bin/boblight-constant@@-p@@255@@-f@@-s@@172.16.40.132@@' + hexValue)
} else {
lsBoblight.sendCommand(0)
}
end