Almost there:
I am bit unsure how to do the for.each member in rules:
/*testcomment*/
import org.openhab.core.library.types.*
var HSBType hsbValue
var HSBType hsbValue2
var String redValue
var String greenValue
var String blueValue
rule "Set RGB value"
when
Item lampColor changed
then
hsbValue = lampColor.state as HSBType
Group_Light.members.forEach( s |
if s.state = ON{
sendCommand( s, hsbValue))
}
end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Switch the different areas where LED-Lights should be switched on/off ////////////////7////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rule "changeLightGroup"
when
Item groupSelector received command
then
if (receivedCommand==1) {
Group_Tv.members.forEach( s | sendCommand( s, hsbValue2))
}
if (receivedCommand==2) {
Group_Dinner.members.forEach( s | sendCommand( s, hsbValue2))
}
if (receivedCommand==3) {
Group_Reading.members.forEach( s | sendCommand( s, hsbValue2))
}
if (receivedCommand==4) {
hsbValue2 = new HSBType(new DecimalType(060),new PercentType(000),new PercentType(000))
Group_Light.members.forEach( s | sendCommand( s, hsbValue2))
}
end
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// Change the moodings of light, e.g. warm white, white, lounge and night ////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rule "changeLightMood"
when
Item moodSelector received command
then
//warm white
if (receivedCommand==1) {
hsbValue2 = new HSBType(new DecimalType(060),new PercentType(100),new PercentType(100))
lampColor.sendCommand(hsbValue2)
}
//white
if (receivedCommand==2) {
hsbValue2 = new HSBType(new DecimalType(0),new PercentType(0),new PercentType(100))
sendCommand(lampColor,hsbValue2)
}
//lounge
if (receivedCommand==3) {
hsbValue2 = new HSBType(new DecimalType(300),new PercentType(100),new PercentType(50))
sendCommand(lampColor,hsbValue2)
}
//night
if (receivedCommand==4) {
hsbValue2 = new HSBType(new DecimalType(000),new PercentType(100),new PercentType(50))
sendCommand(lampColor,hsbValue2)
}
Group_Light.members.forEach( s |
if s.state = ON{
sendCommand( s, hsbValue2))
}
end
And here are my items defined:
Group Group_Kitchen
Group Group_LivingRoom
Group Group_Light
Group Group_Bar
Group Group_Tv
Group Group_Dinner
Color LL1 "LL1"(Group_Light,Group_Kitchen) {dmx="CHANNEL[25,26,27:1000]"}
Color LL2 "LL2"(Group_Light,Group_Kitchen) {dmx="CHANNEL[22,23,24:1000]"}
Color LL3 "LL3"(Group_Light,Group_Kitchen) {dmx="CHANNEL[19,20,21:1000]"}
Color LL4 "LL4"(Group_Light,Group_Tv,Group_Dinner) {dmx="CHANNEL[16,17,18:1000]"}
Color LL5 "LL5"(Group_Light,Group_Tv,Group_Dinner) {dmx="CHANNEL[13,14,15:1000]"}
Color LL6 "LL6"(Group_Light,Group_Kitchen) {dmx="CHANNEL[10,11,12:1000]"}
Color LL7 "LL7"(Group_Light,Group_Kitchen) {dmx="CHANNEL[7,8,9:1000]"}
Color LL8 "LL8"(Group_Light,Group_Dinner) {dmx="CHANNEL[4,5,6:1000]"}
Color LL9 "LL9"(Group_Light,Group_Dinner) {dmx="CHANNEL[1,2,3:1000]"}
Color LL10 "LL10"(Group_Light,Group_Dinner) {dmx="CHANNEL[52,53,54:1000]"}
Color LL11 "LL11"(Group_Light,Group_Kitchen) {dmx="CHANNEL[49,50,51:1000]"}
Color LL12 "LL12"(Group_Light,Group_Kitchen) {dmx="CHANNEL[46,47,48:1000]"}
Color LL13 "LL13"(Group_Light,Group_Kitchen,Group_Dinner) {dmx="CHANNEL[43,44,45:1000]"}
Color LL14 "LL14"(Group_Light,Group_Dinner) {dmx="CHANNEL[40,41,42:1000]"}
Color LL15 "LL15"(Group_Light,Group_Dinner) {dmx="CHANNEL[37,38,39:1000]"}
Color LL16 "LL16"(Group_Light,Group_Tv,Group_Reading) {dmx="CHANNEL[34,35,36:1000]"}
Color LL17 "LL17"(Group_Light,Group_Reading) {dmx="CHANNEL[31,32,33:1000]"}
Color LL18 "LL18"(Group_Light,Group_Reading) {dmx="CHANNEL[28,29,30:1000]"}
Color LL19 "LL19"(Group_Light,Group_Reading) {dmx="CHANNEL[79,80,81:1000]"}
Color LL20 "LL20"(Group_Light,Group_Reading) {dmx="CHANNEL[76,77,78:1000]"}
Color LL21 "LL21"(Group_Light,Group_Reading) {dmx="CHANNEL[73,74,75:1000]"}
Color LL22 "LL22"(Group_Light,Group_Reading) {dmx="CHANNEL[70,71,72:1000]"}
Color LL23 "LL23"(Group_Light,Group_Reading) {dmx="CHANNEL[67,68,69:1000]"}
Color LL24 "LL24"(Group_Light,Group_Reading) {dmx="CHANNEL[64,65,66:1000]"}
Color LL25 "LL25"(Group_Light,Group_Reading) {dmx="CHANNEL[61,62,63:1000]"}
Color LL26 "LL26"(Group_Light,Group_Reading) {dmx="CHANNEL[58,59,60:1000]"}
Color LL27 "LL27"(Group_Light,Group_Reading) {dmx="CHANNEL[55,56,57:1000]"}
Color LL28 "LL28"(Group_Light,Group_Reading) {dmx="CHANNEL[106,107,108:1000]"}
Color LL29 "LL29"(Group_Light,Group_Reading) {dmx="CHANNEL[103,104,105:1000]"}
Color LL30 "LL30"(Group_Light,Group_Reading) {dmx="CHANNEL[100,101,102:1000]"}
Color LB1 "LB1"(Group_Light,Group_Bar) {dmx="CHANNEL[97,98,99:1000]"}
Color LB2 "LB2"(Group_Light,Group_Bar) {dmx="CHANNEL[94,95,96:1000]"}
Color LB3 "LB3"(Group_Light,Group_Bar) {dmx="CHANNEL[91,92,93:1000]"}
Color LB4 "LB4"(Group_Light,Group_Bar) {dmx="CHANNEL[88,89,90:1000]"}
Color LB5 "LB5"(Group_Light,Group_Bar) {dmx="CHANNEL[85,86,87:1000]"}
Color LB6 "LB6"(Group_Light,Group_Bar) {dmx="CHANNEL[82,83,84:1000]"}
Color lampColor "theLampColor" /*holds the selected color scheme*/
Number groupSelector "Group" <sofa> // any idea which icon to use?
Number moodSelector "Mood" <sofa> // any idea which icon to use?
What is the refresh rate :1000 meaning? Should i increase this to 100000? Because when a rule get executed it get updated instant anyway right?
And are
var HSBType hsbValue
var HSBType hsbValue2
global variables that are kept as long as openhab is running or do I need to define it as items instead, and how to do this?
Can I call a rule from a rule?