Hi everybody,
I’m stuck with a rule.
I use openhabian 2.5.3.1
with ikea tradfri binding.
to control my lights i use multiple rules scenes schemas: diner scene, evening scene and so on, such as:
rule "Ambiance soir"
when
Item Ambiance_du_Soir received command ON
then
Niche_Droite.sendCommand(30)
Niche_Gauche.sendCommand(30)
Niche_Milieu.sendCommand(60)
Lumieres_TV.sendCommand(60)
Plafond_Entree_2.sendCommand(0)
Plafond_Entree_3.sendCommand(40)
Plafond_Entree_4.sendCommand(0)
Plafond_Entree_1.sendCommand(40)
Plafond_Salle_A_Manger_1.sendCommand(30)
Plafond_Salle_A_Manger_2.sendCommand(40)
Plafond_Salle_A_Manger_3.sendCommand(30)
ArcheDroite.sendCommand(20)
ArcheGauche.sendCommand(20)
ArcheMilieu.sendCommand(0)
Lumieres_Cuisine.sendCommand(80)
Lampe_Ambiance_Entree.sendCommand(50)
Lampe_Ambiance_Entree_ColorTemperature.sendCommand(40)
Lustre_1.sendCommand(15)
LustreColorTemperature.sendCommand(0)
LustreColor.sendCommand("39,85,84")
Lumieres.postUpdate(ON)
Ambiance_Apero.postUpdate(OFF)
Ambiance_Diner.postUpdate(OFF)
Ambiance_Matin.postUpdate(OFF)
Ambiance_Film_Tele.postUpdate(OFF)
Ambiance_Tele.postUpdate(OFF)
Ambiance_Pleine_lumiere.postUpdate(OFF)
Ambiance_du_Soir.postUpdate(ON)
Ambiance_cosy.postUpdate(OFF)
Ambiance_VP.postUpdate(OFF)
Ambiance_feutree.postUpdate(OFF)
Ambiance_pluie.postUpdate(OFF)
//Bureau.postUpdate(OFF)
logInfo("Ambiance", "Ambiance soir")
end
rule "Ambiance_Diner"
when
Item Ambiance_Diner received command ON
then
Niche_Droite.sendCommand(50)
Niche_Gauche.sendCommand(50)
Niche_Milieu.sendCommand(50)
Lumieres_TV.sendCommand(40)
Plafond_Entree_2.sendCommand(60)
Plafond_Entree_3.sendCommand(60)
Plafond_Entree_4.sendCommand(0)
Plafond_Entree_1.sendCommand(0)
Plafond_Salle_A_Manger_1.sendCommand(100)
Plafond_Salle_A_Manger_2.sendCommand(100)
Plafond_Salle_A_Manger_3.sendCommand(100)
ArcheDroite.sendCommand(80)
ArcheGauche.sendCommand(80)
ArcheMilieu.sendCommand(50)
Lumieres_Cuisine.sendCommand(100)
Lampe_Ambiance_Entree.sendCommand(80)
Lampe_Ambiance_Entree_ColorTemperature.sendCommand(20)
Lustre_1.sendCommand(80)
LustreColorTemperature.sendCommand(90)
Lumieres.postUpdate(ON)
Ambiance_Apero.postUpdate(OFF)
Ambiance_Diner.postUpdate(ON)
Ambiance_Matin.postUpdate(OFF)
Ambiance_Film_Tele.postUpdate(OFF)
Ambiance_Tele.postUpdate(OFF)
Ambiance_Pleine_lumiere.postUpdate(OFF)
Ambiance_du_Soir.postUpdate(OFF)
Ambiance_cosy.postUpdate(OFF)
Ambiance_VP.postUpdate(OFF)
Ambiance_feutree.postUpdate(OFF)
Ambiance_pluie.postUpdate(OFF)
//Bureau.postUpdate(OFF)
logInfo("Ambiance", "Ambiance diner")
end
any of them are triggered trought prescence detection or time cron or timer, i know that i can simplify my rules (using design patern) but this method is the one that i can understand.
i want to integrate a slow dimmer between each scene for example slowly dimme light from evening scene to diner scene, to be more precise, dimme light from 30% to 60% during 45 min for example.
i’m testing this kind of rule:
var Timer Timer0 = null
rule "morning alarm"
when
Time cron "0 32 10 1/1 * ? *"
then
logInfo("morningAlarm", "Wakeup Started")
if(G_Presence.state == ON && Timer0 === null) {
Timer0 = createTimer(now.plusSeconds(1)) [ |
if ((Niche_Milieu.state as Number) < 100) {
Niche_Milieu.sendCommand((Niche_Milieu.state as Number) + 10) 10
Timer0.reschedule(now.plusMinutes(1))
}
else
Timer0 = null
]
}
else if(Niche_Milieu.state==ON) {
Niche_Milieu.sendCommand(OFF)
Timer0.cancel
Timer0 = null
logInfo("morningAlarm", "Wakeup Ended")
}
end
i found a rule example that can correspond to my schema, but i’m stuck with departure value to a specific one.
Can you please put me on the right direction