Did write a few scenes for myself - maybe you can use a bit of that:
Items:
Group GScenes
"Alle Szenen"
<mediacontrol>
(Functions)
Number Scene_Hue_Color_All
"Farb-Szenen"
<colorlight>
(GScenes)
Number Scene_Hue_Color_Bedroom
"Farb-Szenen Schlafzimmer"
<colorlight>
(GScenes)
Number Scene_Hue_Color_Corridor
"Farb-Szenen Flur"
<colorlight>
(GScenes)
Number Scene_Hue_Color_Left_Cabinet
"Farb-Szenen linke Vitrine"
<colorlight>
(GScenes)
Number Scene_Hue_Color_Right_Cabinet
"Farb-Szenen rechte Vitrine"
<colorlight>
(GScenes)
// Example, doesn't make sense to post all lights
Group Hue_LR_Showcase_Left
"Hue Vitrine links"
<light>
(Livingroom, Items)
Switch Hue_LR_Showcase_Left_Switch
"Hue Vitrine links Schalter"
<light>
(Hue_LR_Showcase_Left, GPower, GColor_Lights)
{ channel="hue:0210:ecb5fa004e07:stripe2:color" }
Dimmer Hue_LR_Showcase_Left_Brightness
"Hue Vitrine links Helligkeit [%d %%]"
<light>
(Hue_LR_Showcase_Left)
{ channel="hue:0210:ecb5fa004e07:stripe2:color" }
Color Hue_LR_Showcase_Left_Color
"Hue Vitrine links Farbe"
<colorwheel>
(Hue_LR_Showcase_Left, GColors)
[ "Lighting" ]
{ channel="hue:0210:ecb5fa004e07:stripe2:color" }
Dimmer Hue_LR_Showcase_Left_Temperature
"Hue Vitrine links Farbtemperatur [%d %%]"
<rgb>
(Hue_LR_Showcase_Left)
{ channel="hue:0210:ecb5fa004e07:stripe2:color_temperature" }
String Hue_LR_Showcase_Left_Alert
"Hue Vitrine links Alarm"
<alarm>
(Hue_LR_Showcase_Left)
{ channel="hue:0210:ecb5fa004e07:stripe2:alert" }
Switch Hue_LR_Showcase_Left_Effect
"Hue Vitrine links Effekt"
<party>
(Hue_LR_Showcase_Left)
{ channel="hue:0210:ecb5fa004e07:stripe2:effect" }
Rules:
val String rulesDomaine = "colorscenes.rules"
/*
HSB string values consist of three comma-separated values for
- hue (0-360°),
- saturation (0-100%),
- and brightness (0-100%)
respectively, e.g.
* 0 for red
* 120 for green
* 200 for turquoise
* 240 for blue
* 270 for violett
*/
var Timer rotateTimer = null
val Number timeInBetweenRotations = 10 // in minutes
/*
Set colors for all color lights
370 = warm light
400 = rotate (sync)
410 = rotate (async)
420 = color gradient
999 = scenes off
*/
rule "Set Colors"
when
Item Scene_Hue_Color_All received command
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand > 370) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Colors\" triggered")
// 2. Calculate what needs to be done.
// if timer != null -> cancel
rotateTimer?.cancel
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
// Only if all color lights are off, switch them all on
if (GColor_Lights.state == OFF) {
GColor_Lights.sendCommand(ON)
}
Scene_Hue_Color_Bedroom.sendCommand(receivedCommand)
Scene_Hue_Color_Corridor.sendCommand(receivedCommand)
Scene_Hue_Color_Left_Cabinet.sendCommand(receivedCommand)
Scene_Hue_Color_Right_Cabinet.sendCommand(receivedCommand)
end
rule "Rotate Colors - Syncron"
when
Item Scene_Hue_Color_All received command 400
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 400) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Rotate Colors - Syncron\" triggered")
// 2. Calculate what needs to be done.
// if timer != null -> cancel
rotateTimer?.cancel
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
// Only if all color lights are off, switch them all on
if (GColor_Lights.state == OFF) {
GColor_Lights.sendCommand(ON)
}
rotateTimer = createTimer(now, [ |
var Number color = (Math::random * 360.0).intValue + 1
Scene_Hue_Color_Bedroom.sendCommand(color)
Scene_Hue_Color_Corridor.sendCommand(color)
Scene_Hue_Color_Left_Cabinet.sendCommand(color)
Scene_Hue_Color_Right_Cabinet.sendCommand(color)
rotateTimer.reschedule(now.plusMinutes(timeInBetweenRotations))
])
end
rule "Rotate Colors - Asyncron"
when
Item Scene_Hue_Color_All received command 410
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 410) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Rotate Colors - Asyncron\" triggered")
// 2. Calculate what needs to be done.
// if timer != null -> cancel
rotateTimer?.cancel
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
// Only if all color lights are off, switch them all on
if (GColor_Lights.state == OFF) {
GColor_Lights.sendCommand(ON)
}
rotateTimer = createTimer(now, [ |
Scene_Hue_Color_Bedroom.sendCommand((Math::random * 360.0).intValue + 1)
Scene_Hue_Color_Corridor.sendCommand((Math::random * 360.0).intValue + 1)
Scene_Hue_Color_Left_Cabinet.sendCommand((Math::random * 360.0).intValue + 1)
Scene_Hue_Color_Right_Cabinet.sendCommand((Math::random * 360.0).intValue + 1)
rotateTimer.reschedule(now.plusMinutes(timeInBetweenRotations))
])
end
rule "Color Gradient"
when
Item Scene_Hue_Color_All received command 420
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 420) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Color Gradient\" triggered")
// 2. Calculate what needs to be done.
// if timer != null -> cancel
rotateTimer?.cancel
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
// Only if all color lights are off, switch them all on
if (GColor_Lights.state == OFF) {
GColor_Lights.sendCommand(ON)
}
rotateTimer = createTimer(now, [ |
var Number color = Integer::parseInt(Hue_LR_Showcase_Left_Color.state.toString.split(",").get(0))
if (color >= 359) {
color = 0
} else {
color = color + 1
}
Scene_Hue_Color_Bedroom.sendCommand(color)
Scene_Hue_Color_Corridor.sendCommand(color)
Scene_Hue_Color_Left_Cabinet.sendCommand(color)
Scene_Hue_Color_Right_Cabinet.sendCommand(color)
rotateTimer.reschedule(now.plusSeconds(60))
])
end
rule "End Timer"
when
Item GColor_Lights changed from ON to OFF or
Item Scene_Hue_Color_All changed to 999
then
logInfo(rulesDomaine, "Rule \"End Timer\" triggered")
rotateTimer?.cancel
//Scene_Hue_Color_All.sendCommand(999)
end
rule "Resume Timer"
when
Item GColor_Lights changed from OFF to ON
then
if (Scene_Sunrise.state == ON) return
logInfo(rulesDomaine, "Rule \"Resume Timer\" triggered with state: " +
Scene_Hue_Color_All.state)
Scene_Hue_Color_All.sendCommand(Scene_Hue_Color_All.state as Number)
end
rule "Set Color Bedroom"
when
Item Scene_Hue_Color_Bedroom received command
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand > 360) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Bedroom\" triggered")
// 2. Calculate what needs to be done.
var String color = receivedCommand.toString
var String brightness = Hue_BR_Wardrobe_Color.state.toString.split(",").get(2)
var String hsb_triple = color + ",100," + brightness
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_BR_Wardrobe_Color.sendCommand(hsb_triple)
end
rule "Set Color Corridor"
when
Item Scene_Hue_Color_Corridor received command
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand > 360) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Corridor\" triggered")
// 2. Calculate what needs to be done.
var String color = receivedCommand.toString
var String brightness = Hue_C_Lamp_Color.state.toString.split(",").get(2)
var String hsb_triple = color + ",100," + brightness
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_C_Lamp_Color.sendCommand(hsb_triple)
end
rule "Set Color Left Cabinet"
when
Item Scene_Hue_Color_Left_Cabinet received command
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand > 360) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Left Cabinet\" triggered")
// 2. Calculate what needs to be done.
var String color = receivedCommand.toString
var String brightness = Hue_LR_Showcase_Left_Color.state.toString.split(",").get(2)
var String hsb_triple = color + ",100," + brightness
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_LR_Showcase_Left_Color.sendCommand(hsb_triple)
end
rule "Set Color Right Cabinet"
when
Item Scene_Hue_Color_Right_Cabinet received command
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand > 360) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Right Cabinet\" triggered")
// 2. Calculate what needs to be done.
var String color = receivedCommand.toString
var String brightness = Hue_LR_Showcase_Right_Color.state.toString.split(",").get(2)
var String hsb_triple = color + ",100," + brightness
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_LR_Showcase_Right_Color.sendCommand(hsb_triple)
end
rule "Set Color Bedroom - Warm Light"
when
Item Scene_Hue_Color_Bedroom received command 370
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 370) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Bedroom - Warm Light\" triggered")
// 2. Calculate what needs to be done.
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_BR_Wardrobe_Temperature.sendCommand(100)
end
rule "Set Color Corridor - Warm Light"
when
Item Scene_Hue_Color_Corridor received command 370
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 370) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Corridor - Warm Light\" triggered")
// 2. Calculate what needs to be done.
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_C_Lamp_Temperature.sendCommand(100)
end
rule "Set Color Left Cabinet - Warm Light"
when
Item Scene_Hue_Color_Left_Cabinet received command 370
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 370) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Left Cabinet - Warm Light\" triggered")
// 2. Calculate what needs to be done.
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_LR_Showcase_Left_Temperature.sendCommand(100)
end
rule "Set Color Right Cabinet - Warm Light"
when
Item Scene_Hue_Color_Right_Cabinet received command 370
then
// 1. Check to see if the Rule has to run at all, if not exit.
if( receivedCommand != 370) return;
// Only log if rule applies
logInfo(rulesDomaine, "Rule \"Set Color Right Cabinet - Warm Light\" triggered")
// 2. Calculate what needs to be done.
// 3. Do it. Only do actions in like sendCommand in one place at the end of the Rule.
Hue_LR_Showcase_Right_Temperature.sendCommand(100)
end
Sitemap:
Selection item=Scene_Hue_Color_All
label="Farbszenen"
mappings=[
999="Aus",
0="Rot",
120="Grün",
200="Türkis",
240="Blau",
270="Violett",
370="Warmes Licht",
400="Wechselnde Farben (synchronisiert)",
410="Wechselnde Farben (asynchron)",
420="Farbverlauf"
]
Switch item=Hue_LR_Showcase_Right_Switch
label="Vitrine rechts"
mappings=[ON="Ein"]
visibility=[Hue_LR_Showcase_Right_Switch != ON]
Text item=Hue_LR_Showcase_Right_Switch
label="Vitrine rechts [MAP(lights.map):%s]"
valuecolor=[ON="green", OFF="maroon"]
visibility=[Hue_LR_Showcase_Right_Switch == ON] {
Default item=Hue_LR_Showcase_Right_Brightness
label="Helligkeit"
Default item=Hue_LR_Showcase_Right_Temperature
label="Farbtemperatur"
Default item=Hue_LR_Showcase_Right_Color
label="Farbton"
Switch item=Hue_LR_Showcase_Right_Switch
label="Lichtband"
mappings=[OFF="Aus"]
Switch item=Hue_LR_Showcase_Right_Alert
label="Alarm [MAP(lights.map):%s]"
mappings=[NONE="Aus", SELECT="Alarm", LSELECT="Langer Alarm"]
Selection item=Scene_Hue_Color_Right_Cabinet
label="Farbszenen"
mappings=[
0="Rot",
120="Grün",
200="Türkis",
240="Blau",
270="Violett",
370="Warmes Licht"
]