I have three rules that are for selecting a scene in a bedroom, setting the lights to hsb-values. Inspired by the rulesDP from Rich I was thinking about combining these three rules into one. Do you think this is possible?
I have a string-Item to hold the Scene-name, and a color item per room.
Here is my rule (which is repeated for the other rooms):
rule “Scenes BR1”
when
Item Scene_BR1 changed
then
var String hsb = “0,0,0” //set variable
switch Scene_BR1 {
case Scene_BR1.state.toString == “WERK”: {
hsb = “30,60,100”
} case Scene_BR1.state.toString == “GEZEL”: {
hsb = “20,100,49”
} case Scene_BR1.state.toString == “DAG”: {
hsb = “45,9,100”
} case Scene_BR1.state.toString == “NACHT”: {
hsb = “27,100,1”
}
}
Color_BR.sendCommand(hsb)
logInfo(“Scene BR1”, “BR1’s Scene: '” + Scene_BR1.state.toString +“', met HSB=(” + hsb +“)”)
end
So I thought maybe I can trigger the rule by a group gScene_BRx (Scene_BR1, Scene_BR2, etc).
Then I can get which item triggered the rule by Member of gScenes_BR. But I have no idea how I can set the Color of the right bedroom: Color_BR1, Color_BR2, or Color_BR3?
rule “Scenes BR’s”
when
Member of gScenes_BRx changed
then
var String hsb = “0,0,0” //set variable
switch triggeringItem {
case triggeringItem.state.toString == “WERK”: {
hsb = “30,60,100”
} case triggeringItem.state.toString == “GEZEL”: {
hsb = “20,100,49”
} case triggeringItem.state.toString == “DAG”: {
hsb = “45,9,100”
} case triggeringItem.state.toString == “NACHT”: {
hsb = “27,100,1”
}
}
Color_BR[1, 2, or3].sendCommand(hsb)
logInfo(“Scene_BR1-2-3”, " Scene: ‘" + Scene_BR1-2-3.state.toString +"’, met HSB=(" + hsb +“)”)
end