Continuing the discussion from Timers for on/off delay:
Inspired by @snoekieboe post, I’m controlling my blinds with this timer rule. I have a sun sensor, and when it’s activated (ON), the blinds move down, and when it’s deactivated (OFF) the blinds move up after “blinds_timeout” minutes, preferred to be 30 minutes in my case
And it’s almost behaving as I wish, except from the “blinds_timeout” time. If the sun sensor is activated (ON) the timer is rescheduled every 30 minutes. If 25 minutes has elapsed, and the sun sensor is deactivated (OFF), the blinds moves up after only 5 minutes. With no luck, I have tried to figure out how to modify the rule, so the timer could be kind of rescheduled when the sun sensor gets deactivated (OFF), and I will then achieve the 30 minute delay, before the blinds moves up.
var Timer blinds_timer = null
var Integer blinds_timeout = 30
rule "SunlightBlindsControl"
when
Item V_BC1_Solsensor received update
then
if (V_BC1_Solsensor.state == ON) {
if (blinds_timer !== null)
{
blinds_timer.reschedule(now.plusMinutes(blinds_timeout))
logInfo("Blinds","Blinds timer rescheduled for " + blinds_timeout + " minutes")
}
else
{
logInfo("Blinds","Blinds timer created for " + blinds_timeout + " minutes")
if (H_Position.state < 59){
H_HelOp.sendCommand(OFF)
H_HalvNed.sendCommand(ON)
}
if (J_Position.state < 57){
J_HelOp.sendCommand(OFF)
J_HalvNed.sendCommand(ON)
}
RuleSunlightBlindsControlTS.postUpdate( new DateTimeType() )
blinds_timer = createTimer(now.plusMinutes(blinds_timeout))
[|
if (V_BC1_Solsensor.state == ON)
{
blinds_timer.reschedule(now.plusMinutes(blinds_timeout))
logInfo("Blinds","Blinds timer triggered, but rescheduled again for " + blinds_timeout + " minutes")
}
else
{
logInfo("Blinds","Blinds timer expired")
if (H_Position.state > 0){
H_HalvNed.sendCommand(OFF)
H_HelOp.sendCommand(ON)
}
if (J_Position.state > 0){
J_HalvNed.sendCommand(OFF)
J_HelOp.sendCommand(ON)
}
blinds_timer = null
}
]
}
}
end
Since this example is intended to be used for light control, and often with a much lower timer value I guess, the rule of course behave as it should. So, I’m asking for help to modify it for my purpose.
Best regards Ole.