Hi to all,
I have created some dynamic light scenes and I struggled with many problems before getting it to work. I would really be happy for some hints to make things easier or if not possible confirmation that this is a good way to do it.
I have two Ikea lamps on a feet that are like a long tube with 3 zones with bulbs, let's say bottom, middle and top. The dynamic scene I present here will start with a moon color (4000k) with 90% intensity in the middle and sun color (2200K) with 15% intensity in the bottom and top zone.
The dynamic changes are:
First the top color and intensity change on a defined time period (3 minutes) to 4000:90 while the middle color changes in the same time to 2200:15. This makes the bright moon color wandering very softly from the middle to the top. Then the moon color wanders to the bottom field and then to the middle again (back to initial states). This cycle repeats endless until stopped. I use private boolean to assure that only one instance of the rule runs.
As I installed multiple dynamic scene rules, I use a hub variable to know the scene that runs, or zero if no scene runs and so on. I also use this to assure that a scene is stopped if I start another one. A rule on lights turning OFF setting this variable to 0 assures that the scene stops and does not turn the light on again.
The hub variable is : vDynamicSceneTVlamp
The rule variables are the following:
I use these local variables for internal rule requirements (scene/SlotChanged) but also to be able to change color temperatures, dimmers and time the easy way without any changes in the rule itself.
Here is the rule
IF (Private Boolean(true) is false(F) [FALSE]) THEN
Exit Rule
END-IF
Set Private Boolean(true) False
Comment: ==================> Initialize states and variables
Color Temperature: Ikea Bulb Lampadaire (01) gauche bas, Ikea Bulb Lampadaire (03) gauche haut, Ikea Bulb Lampadaire (04) droite bas, Ikea Bulb Lampadaire (06) droite haut: cSunColor(2200): LowIntensity(15)
Color Temperature: Ikea Bulb Lampadaire (05) droite milieu, Ikea Bulb Lampadaire (02) gauche milieu: cMoonColor(4000): High Intensity(90)
Set Scene to 1
Set SlotChanged to true
Set vDynamicSceneTVlamp to 1
Comment: ==================> Loop and check every 10 seconds for changes
Repeat every 0:00:10 (stoppable)
Comment: =================> If Scene is deactivated - Turn Timers OFF and Exit
IF (Variable vDynamicSceneTVlamp(0) != 1(T) [TRUE]) THEN
Cancel Timed Actions: **This Rule**
Set Private Boolean(true) True
Log: 'Moonrise : Check for stop was run'
Exit Rule
END-IF
Comment: ==================> Check for required scene change and initiate it
IF (Ikea Bulb Lampadaire (03) gauche haut colorTemperature(2801) >= cMoonColor(4000) (F) [FALSE]) THEN
Set SlotChanged to true
Set Scene to 2
END-IF
IF (Ikea Bulb Lampadaire (01) gauche bas colorTemperature(2801) >= cMoonColor(4000) (F) [FALSE]) THEN
Set SlotChanged to true
Set Scene to 3
END-IF
IF (Ikea Bulb Lampadaire (02) gauche milieu colorTemperature(2801) >= cMoonColor(4000) (F) [FALSE]) THEN
Set SlotChanged to true
Set Scene to 1
END-IF
Comment: ==================> Start initiated scene changes
IF (Variable Scene(3) = 1(F) AND
Variable SlotChanged(false) = true(F) [FALSE]) THEN
Set SlotChanged to false
Change Ikea Bulb Lampadaire (05) droite milieu, Ikea Bulb Lampadaire (02) gauche milieu down to cSunColor(2200) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (05) droite milieu, Ikea Bulb Lampadaire (02) gauche milieu down to LowIntensity(15) over TimeSlot(3) minutes with 10.0 seconds interval
Change Ikea Bulb Lampadaire (03) gauche haut, Ikea Bulb Lampadaire (06) droite haut up to cMoonColor(4000) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (03) gauche haut, Ikea Bulb Lampadaire (06) droite haut up to High Intensity(90) over TimeSlot(3) minutes with 10.0 seconds interval
END-IF
IF (Variable Scene(3) = 2(F) AND
Variable SlotChanged(false) = true(F) [FALSE]) THEN
Set SlotChanged to false
Change Ikea Bulb Lampadaire (04) droite bas, Ikea Bulb Lampadaire (01) gauche bas up to cMoonColor(4000) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (04) droite bas, Ikea Bulb Lampadaire (01) gauche bas up to High Intensity(90) over TimeSlot(3) minutes with 10.0 seconds interval
Change Ikea Bulb Lampadaire (03) gauche haut, Ikea Bulb Lampadaire (06) droite haut down to cSunColor(2200) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (03) gauche haut, Ikea Bulb Lampadaire (06) droite haut down to LowIntensity(15) over TimeSlot(3) minutes with 10.0 seconds interval
END-IF
IF (Variable Scene(3) = 3(T) AND
Variable SlotChanged(false) = true(F) [FALSE]) THEN
Set SlotChanged to false
Change Ikea Bulb Lampadaire (04) droite bas, Ikea Bulb Lampadaire (01) gauche bas down to cSunColor(2200) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (04) droite bas, Ikea Bulb Lampadaire (01) gauche bas down to LowIntensity(15) over TimeSlot(3) minutes with 10.0 seconds interval
Change Ikea Bulb Lampadaire (05) droite milieu, Ikea Bulb Lampadaire (02) gauche milieu up to cMoonColor(4000) over TimeSlot(3) minutes with 10.0 seconds interval
Fade Ikea Bulb Lampadaire (05) droite milieu, Ikea Bulb Lampadaire (02) gauche milieu up to High Intensity(90) over TimeSlot(3) minutes with 10.0 seconds interval
END-IF
END-REP