Big Christmas tree (9m x 5m), driven by openHAB.
Random change of lights and predefined colours, based no timer. Hardware is 42x Ikea RGB light bulbs in IBC containers.
Some technical details:
items:
Group ibcBoom "IBC Boom" <garden>
Group ibcSettings "Instellingen" <settings>
Switch ibcEnable "Activeer scenario" <switch>
Group lightCol "Alle lampen" <light>
String ibcAll "Alle lampen" <colorpicker>
Group lightColALL "Alle lampen" <light>
Group lightDim "Dim Group"
Group colorScheme "Color Group"
Group hslScheme "HSL Group"
Switch ibcColor01 "Wit" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor02 "Orange" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor03 "Geel" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor04 "Groen" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor05 "Blauw" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor06 "Paars" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor07 "Rood" <colorpicker> (colorScheme) // disable/enable color
Switch ibcColor08 "Uit" <colorpicker> (colorScheme) // disable/enable color
String ibcHSL01 "Wit" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL02 "Orange" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL03 "Geel" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL04 "Groen" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL05 "Blauw" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL06 "Paars" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL07 "Rood" <colorpicker> (hslScheme) // disable/enable color
String ibcHSL08 "Uit" <colorpicker> (hslScheme) // disable/enable color
Dimmer ibc01LDimmer "Lamp 01" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65537:color_temperature" }
Color ibc01LColor "Lamp 01" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65537:color" }
Dimmer ibc02LDimmer "Lamp 02" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65538:color_temperature" }
Color ibc02LColor "Lamp 02" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65538:color" }
Dimmer ibc03LDimmer "Lamp 03" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65539:color_temperature" }
Color ibc03LColor "Lamp 03" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65539:color" }
Dimmer ibc04LDimmer "Lamp 04" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65540:color_temperature" }
Color ibc04LColor "Lamp 04" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65540:color" }
Dimmer ibc05LDimmer "Lamp 05" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65541:color_temperature" }
Color ibc05LColor "Lamp 05" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65541:color" }
...
Color ibc41LColor "Lamp 41" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65577:color" }
Dimmer ibc42LDimmer "Lamp 42" (lightDim) { channel="tradfri:0210:gw707414b8fc49:65578:color_temperature" }
Color ibc42LColor "Lamp 42" (lightCol) { channel="tradfri:0210:gw707414b8fc49:65578:color" }
Group ibcTiming "Timegroup"
Switch ibcTime1 "Ochtend [%s]" <time>
Switch ibcTime2 "Avond [%s]" <time>
Number ibcStartHour1 "Start [%d u]" <time> (ibcTiming)
Number ibcStartMinute1 "Start [%d m]" <time> (ibcTiming)
Number ibcEndHour1 "Eind [%d u]" <time> (ibcTiming)
Number ibcEndMinute1 "Eind [%d m]" <time> (ibcTiming)
Number ibcStartHour2 "Start [%d u]" <time> (ibcTiming)
Number ibcStartMinute2 "Start [%d m]" <time> (ibcTiming)
Number ibcEndHour2 "Eind [%d u]" <time> (ibcTiming)
Number ibcEndMinute2 "Eind [%d m]" <time> (ibcTiming)```
Rule:
// ----------------------------------
// | Random time, lights and colors |
// ----------------------------------
var Timer tRandomLights = null
val java.util.Random rand = new java.util.Random
rule "IBC boom randomly AAN"
when
Time cron "0/10 * * * * ?"
then
if (ibcEnable.state == ON && ((ibcTime1.state == ON) || (ibcTime2.state == ON))) {
// Choose Random colors
val colorsPossible = hslScheme.allMembers.filter(s | s.state != "0,0,0").map[ state ]
var colorChoice = rand.nextInt(colorsPossible.size-1)
var colorUse = colorsPossible.get(colorChoice)
logInfo("org.openhab","IBC2 Random Color " + colorUse)
// Choose Random Light, based on list)
if ((new java.util.Random).nextInt(2) == 1) {
var int randomTime = (new java.util.Random).nextInt(30)
logInfo("org.openhab","IBC3 setting random lights timer to " + randomTime + " seconds.")
tRandomLights = createTimer(now.plusSeconds(randomTime)) [|
var icbRandLightIndex = (new java.util.Random).nextInt(lightCol.members.size)
if (ibcEnable.state == ON && ((ibcTime1.state == ON) || (ibcTime2.state == ON))) {
sendCommand(lightCol.members.get(icbRandLightIndex), colorUse.toString)
logInfo("org.openhab","IBC4 Switched light " + lightCol.members.get(icbRandLightIndex).name + " " + colorUse)
}
]
}
}
end
// ----------------------------
// | Convert Switch to colors |
// ----------------------------
rule "Convert Color switch to HSL Wit AAN"
when
System started or
Item ibcColor01 changed to ON
then
ibcHSL01.sendCommand("275,10,100")
end
rule "Convert Color switch to HSL Orange AAN"
when
System started or
Item ibcColor02 changed to ON
then
ibcHSL02.sendCommand("32,90,100")
end
rule "Convert Color switch to HSL Geel AAN"
when
System started or
Item ibcColor03 changed to ON
then
ibcHSL03.sendCommand("56,96,100")
end
rule "Convert Color switch to HSL Groen AAN"
when
System started or
Item ibcColor04 changed to ON
then
ibcHSL04.sendCommand("121,92,100")
end
rule "Convert Color switch to HSL Blauw AAN"
when
System started or
Item ibcColor05 changed to ON
then
ibcHSL05.sendCommand("203,99,100")
end
rule "Convert Color switch to HSL Paars AAN"
when
System started or
Item ibcColor06 changed to ON
then
ibcHSL06.sendCommand("301,92,100")
end
rule "Convert Color switch to HSL Rood AAN"
when
System started or
Item ibcColor07 changed to ON
then
ibcHSL07.sendCommand("354,92,100")
end
rule "Convert Color switch to HSL AAN"
when
System started or
Item ibcColor08 changed to ON
then
ibcHSL08.sendCommand("0,0,1")
end
rule "Convert Color switch to HSL Wit UIT"
when
Item ibcColor01 changed to OFF
then
ibcHSL01.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Orange UIT"
when
Item ibcColor02 changed to OFF
then
ibcHSL02.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Geel UIT"
when
Item ibcColor03 changed to OFF
then
ibcHSL03.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Groen UIT"
when
Item ibcColor04 changed to OFF
then
ibcHSL04.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Blauw UIT"
when
Item ibcColor05 changed to OFF
then
ibcHSL05.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Paars UIT"
when
Item ibcColor06 changed to OFF
then
ibcHSL06.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL Rood UIT"
when
Item ibcColor07 changed to OFF
then
ibcHSL07.sendCommand("0,0,0")
end
rule "Convert Color switch to HSL UIT"
when
Item ibcColor08 changed to OFF
then
ibcHSL08.sendCommand("0,0,0")
end
rule "Alle lampen samen"
when
Item ibcAll changed to "Wit" or
Item ibcAll changed to "Orange" or
Item ibcAll changed to "Geel" or
Item ibcAll changed to "Groen" or
Item ibcAll changed to "Blauw" or
Item ibcAll changed to "Paars" or
Item ibcAll changed to "Rood" or
Item ibcAll changed to "Uit"
then
if (previousState == ".") return;
if (ibcAll.state.toString == "Wit") {lightCol.sendCommand("275,10,100")}
if (ibcAll.state.toString == "Orange") {lightCol.sendCommand("32,90,100")}
if (ibcAll.state.toString == "Geel") {lightCol.sendCommand("56,96,100")}
if (ibcAll.state.toString == "Groen") {lightCol.sendCommand("121,92,100")}
if (ibcAll.state.toString == "Blauw") {lightCol.sendCommand("203,99,100")}
if (ibcAll.state.toString == "Paars") {lightCol.sendCommand("301,92,100")}
if (ibcAll.state.toString == "Rood") {lightCol.sendCommand("354,92,100")}
if (ibcAll.state.toString == "Uit") {lightCol.sendCommand(OFF)}
createTimer(now.plusSeconds(1), [ |
ibcAll.sendCommand(" ")
])
end
// -------------------
// | Time Scheduling |
// -------------------
rule "set workstate Morning"
when
Time cron "0 0/5 * * * ?" or
Member of ibcTiming changed
then
val sH = ibcStartHour1.state as Number
val sM = ibcStartMinute1.state as Number
val eH = ibcEndHour1.state as Number
val eM = ibcEndMinute1.state as Number
var dM = now.getHour() * 60 + now.getMinute()
if (dM >= sM + sH * 60 && dM < eM + eH * 60)
ibcTime1.postUpdate(ON)
else
ibcTime1.postUpdate(OFF)
end
rule "set workstate Evening"
when
Time cron "0 0/5 * * * ?" or
Member of ibcTiming changed
then
val sH2 = ibcStartHour2.state as Number
val sM2 = ibcStartMinute2.state as Number
val eH2 = ibcEndHour2.state as Number
val eM2 = ibcEndMinute2.state as Number
var dM2 = now.getHour() * 60 + now.getMinute()
if (dM2 >= sM2 + sH2 * 60 && dM2 < eM2 + eH2 * 60)
ibcTime2.postUpdate(ON)
else
ibcTime2.postUpdate(OFF)
end
rule "Alles AAN op Groen"
when
Item ibcTime1 changed to ON or
Item ibcTime2 changed to ON
then
lightCol.sendCommand("121,92,100")
end
rule "Alles UIT"
when
System started or
Item ibcTime1 changed to OFF or
Item ibcTime2 changed to OFF
then
createTimer(now.plusSeconds(60), [ |
lightCol.sendCommand(OFF)
])
end
sitemap:
sitemap default label="IBC Boom" {
Frame {
Switch item=ibcEnable
Selection item=ibcAll mappings=[Wit="Wit", Orange="Orange", Geel="Geel", Groen="Groen", Blauw="Blauw", Paars="Paars", Rood="Rood", Uit="Uit" ]
Group item=ibcSettings {
Frame label="Kleuren" {
Switch item=ibcColor01
Switch item=ibcColor02
Switch item=ibcColor03
Switch item=ibcColor04
Switch item=ibcColor05
Switch item=ibcColor06
Switch item=ibcColor07
Switch item=ibcColor08
}
Frame item=ibcTime1 {
Setpoint item=ibcStartHour1 minValue=0 maxValue=12 step=1
Setpoint item=ibcStartMinute1 minValue=0 maxValue=60 step=5
Setpoint item=ibcEndHour1 minValue=0 maxValue=12 step=1
Setpoint item=ibcEndMinute1 minValue=0 maxValue=60 step=5
}
Frame item=ibcTime2 {
Setpoint item=ibcStartHour2 minValue=12 maxValue=23 step=1
Setpoint item=ibcStartMinute2 minValue=0 maxValue=60 step=5
Setpoint item=ibcEndHour2 minValue=12 maxValue=23 step=1
Setpoint item=ibcEndMinute2 minValue=0 maxValue=60 step=5
}
}
}
}
Next year, I want to add:
- More groups (fe layers, cool combinations)
- Variable speed. So that the random timer can be set faster/slower.
- A internet connection to be able to implement sunrise/sunset timings.
- Better way to select the predefined colours (not code base, but RGB picker?)
But not bad for a first edition… 