There are multiple ways to accomplish this. Somewhere on the forum there is a scheduler (graphic one), I couldn’t find fast.
I did it with rules and switches, but for me i’ve only 2 time settings and 2 switches. I’ll share it with you, maybe you can find a path to start to do it.
What it does: I can set a timer to automatic send a command UP(omhoog) or DOWN(omlaag) to my rollershutters (2: back and front).
rules:
rule "auto Timer setting time"
when
Member of RollerShutters_Auto_Timer_HoursMinutes received update
then
logInfo("tijd veranderd",triggeringItem.toString)
val tname = triggeringItem.name
val tdir = tname.split("_").get(3)
RollerShutters_Auto_Timer.members.findFirst[i|i.name.contains(tdir)].sendCommand(OFF)
end
rule "Auto Rollershutter based on time"
when
Member of RollerShutters_Auto_Timer received update
then
val tdir = triggeringItem.name.split("_").get(3)
val tstate = triggeringItem.state
val timer_time = RollerShutters_Auto_Timer_Time.allMembers.findFirst[i|i.name.contains(tdir)]
val timer_hour = (RollerShutters_Auto_Timer_HoursMinutes.allMembers.findFirst[i|i.name.contains(tdir+"_Hour")].state as Number).intValue
val timer_minute = (RollerShutters_Auto_Timer_HoursMinutes.allMembers.findFirst[i|i.name.contains(tdir+"_Minute")].state as Number).intValue
if (now.isBefore(now.withTime(timer_hour,timer_minute,0,0)) ){
timer_time.postUpdate(now.withTime(timer_hour,timer_minute,0,0).toString)
}else{
timer_time.postUpdate(now.withTime(timer_hour,timer_minute,0,0).plusHours(24).toString)
}
if (tstate==ON){
switch tdir{
case "Down" :{
if (RSTimerDown === null){
logInfo("RSTimerDown","start Timer Down")
RSTimerDown = createTimer(new DateTime(RollerShutters_Auto_Timer_Down_Time.state.toString), [|
logInfo("RSTimerDown","Timer wordt uitgevoerd")
RollerShutters_Auto_Timer_Down.allMembers.filter[i|i.state==ON].forEach[i|
checkFirstRS.apply(RollerShutters.members.findFirst[j|j.name.contains(i.name.split("_").get(1))] as GenericItem, DOWN)
]
RollerShutters_Auto_Timer_Down_Time.postUpdate(now.plusDays(1).toString)
RSTimerDown.reschedule(now.plusDays(1))
])
}
}
case "Up" :{
if (RSTimerUp === null){
logInfo("RSTimerUp","start Timer Up")
RSTimerUp = createTimer(new DateTime(RollerShutters_Auto_Timer_Up_Time.state.toString), [|
logInfo("RSTimerUp","Timer wordt uitgevoerd")
RollerShutters_Auto_Timer_Up.allMembers.filter[i|i.state==ON].forEach[i|
checkFirstRS.apply(RollerShutters.members.findFirst[j|j.name.contains(i.name.split("_").get(1))] as GenericItem, UP)
]
RollerShutters_Auto_Timer_Up_Time.postUpdate(now.plusDays(1).toString)
RSTimerUp.reschedule(now.plusDays(1))
])
}
}
}
}else{
switch tdir{
case "Down": {
if (RollerShutters_Auto_Timer_Down.state == OFF){
logInfo("RSTimerDown","stop Timer Down")
RSTimerDown?.cancel
RSTimerDown = null
}
}
case "Up": {
if (RollerShutters_Auto_Timer_Up.state == OFF){
logInfo("RSTimerUp","stop Timer Up")
RSTimerUp?.cancel
RSTimerUp = null
}
}
}
}
end
rule "Trigger Rollershutter based on time rule after refresh or restart"
when
System started
then
logInfo("reset","Timer reset na herstart")
RollerShutters_Auto_Timer?.allMembers.filter[i|i.state == ON].forEach[j|j.postUpdate(ON)]
end
items:
Switch RollerShutters_Front_Auto_Timer_Up "Rolluiken op tijd omhoog voorzijde" (RollerShutters_Auto_Timer_Up)
Switch RollerShutters_Front_Auto_Timer_Down "Rolluiken op tijd omlaag voorzijde" (RollerShutters_Auto_Timer_Down)
Switch RollerShutters_Back_Auto_Timer_Up "Rolluiken op tijd omhoog acherzijde" (RollerShutters_Auto_Timer_Up)
Switch RollerShutters_Back_Auto_Timer_Down "Rolluiken op tijd omlaag achterzijde" (RollerShutters_Auto_Timer_Down)
Switch RollerShutters_Front_Auto_Sun_Up "Rolluiken zon tijd omhoog voorzijde" (RollerShutters_Auto_Timer_Up)
Switch RollerShutters_Front_Auto_Sun_Down "Rolluiken zon tijd omlaag voorzijde" (RollerShutters_Auto_Timer_Down)
Switch RollerShutters_Back_Auto_Sun_Up "Rolluiken zon tijd omhoog acherzijde" (RollerShutters_Auto_Timer_Up)
Switch RollerShutters_Back_Auto_Sun_Down "Rolluiken zon tijd omlaag achterzijde" (RollerShutters_Auto_Timer_Down)
DateTime RollerShutters_Auto_Timer_Up_Time "Rolluiken op tijd ingesteld omhoog [%1$tH:%1$tM]" <time> (RollerShutters_Auto_Timer_Time)
DateTime RollerShutters_Auto_Timer_Down_Time "Rolluiken op tijd ingesteld omlaag [%1$tH:%1$tM]" <time> (RollerShutters_Auto_Timer_Time)
Number RollerShutters_Auto_Timer_Up_Hour "Rolluiken op tijd omhoog uur [%d]" <time> (RollerShutters_Auto_Timer_HoursMinutes)
Number RollerShutters_Auto_Timer_Up_Minute "Rolluiken op tijd omhoog minuten [%d]" <time> (RollerShutters_Auto_Timer_HoursMinutes)
Number RollerShutters_Auto_Timer_Down_Hour "Rolluiken op tijd omlaag uur [%d]" <time> (RollerShutters_Auto_Timer_HoursMinutes)
Number RollerShutters_Auto_Timer_Down_Minute "Rolluiken op tijd omlaag minuten [%d]" <time> (RollerShutters_Auto_Timer_HoursMinutes)
sitemap
Group item=RollerShutters_Auto_Timer {
Frame label="omhoog"{
Text item=RollerShutters_Auto_Timer_Up_Time label="Ingestelde tijd"
Text label="" icon=""
Setpoint item=RollerShutters_Auto_Timer_Up_Hour label="uur" minValue=0 maxValue=23 step=1 visibility=[RollerShutters_Auto_Timer_Up == OFF]
Setpoint item=RollerShutters_Auto_Timer_Up_Minute label="minuten" minValue=0 maxValue=59 step=15 visibility=[RollerShutters_Auto_Timer_Up == OFF]
Switch item=RollerShutters_Front_Auto_Timer_Up label="Voorzijde" mappings=[ON=AAN, OFF=UIT]
Switch item=RollerShutters_Back_Auto_Timer_Up label="Achterzijde" mappings=[ON=AAN, OFF=UIT]
}
Frame label="omlaag"{
Text item=RollerShutters_Auto_Timer_Down_Time label="Ingestelde tijd"
Text label="" icon=""
Setpoint item=RollerShutters_Auto_Timer_Down_Hour label="uur" minValue=0 maxValue=23 step=1 visibility=[RollerShutters_Auto_Timer_Down == OFF]
Setpoint item=RollerShutters_Auto_Timer_Down_Minute label="minuten" minValue=0 maxValue=59 step=15 visibility=[RollerShutters_Auto_Timer_Down == OFF]
Switch item=RollerShutters_Front_Auto_Timer_Down label="Voorzijde" mappings=[ON=AAN, OFF=UIT]
Switch item=RollerShutters_Back_Auto_Timer_Down label="Achterzijde" mappings=[ON=AAN, OFF=UIT]
}
}