[SOLVED] Timer off delay for PowerView blinds

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"
	Item V_BC1_Solsensor received update
	if (V_BC1_Solsensor.state == ON) {   
  	  if (blinds_timer !== null) 
        logInfo("Blinds","Blinds timer rescheduled for " + blinds_timeout + " minutes")
        logInfo("Blinds","Blinds timer created for " + blinds_timeout + " minutes")
            if (H_Position.state < 59){
            if (J_Position.state < 57){
        RuleSunlightBlindsControlTS.postUpdate( new DateTimeType() )
        blinds_timer = createTimer(now.plusMinutes(blinds_timeout)) 
            if (V_BC1_Solsensor.state ==  ON)   
                logInfo("Blinds","Blinds timer triggered, but rescheduled again for " + blinds_timeout + " minutes")                    
            logInfo("Blinds","Blinds timer expired")
                if (H_Position.state > 0){
                if (J_Position.state > 0){
                blinds_timer = null

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.

Don’t use timers, use the expire binding

This Design Pattern will point you in the right direction:

Trigger a Rule for when the sun sensor changes to OFF. In this rule just use:


This one is more specific and has more explanations on Expire: Design Pattern: Expire Binding Based Timers

1 Like

That’s the one I was looking for!!! Could get my hand on it

1 Like

As suggested, I changed my rule to use the Expire binding.

I’m not sure I understand the fully functionality of the Expire binding, but together with the rule it’s behaving as I want. :slight_smile:

Thank you for your contribution!