Item change state and wait time

Thanks, I have this working now after looking in several threads, including here https://community.openhab.org/t/design-pattern-expire-binding-based-timers/32634

For anyone wanting to do something similar keep in mind I am not a coder. I would be interested to hear feedback on my solution.

I created an Item with an expire timer to help keep track of the timer. I can also manually start/stop the timer.

Switch PatioDoorTimer "PatioDoor Timer" {expire="15s,command=OFF"}

Then I created a rule to turn on that timer when the door opens. When the door closes, it sends an update to turn off the timer. It continues to repeat the command every 15 seconds until the door is shut.

Rules:

rule "DoorOpenTimerStart"
when
    Item PatioDoorSensor changed from CLOSED to OPEN
then

PatioDoorTimer.postUpdate ("ON")
    
end


rule "DoorOpenTimerAlert"

when

	Item PatioDoorTimer changed from ON to OFF

then
	if (PatioDoorSensor.state == OPEN)  {
		
		executeCommandLine("flite -voice awb -f /Doors/ShutPatioDoor.txt")
		logInfo("DOOR", "Patio Door Open longer than 15 seconds, reseting Timer")
		PatioDoorTimer.postUpdate ("ON")	
	}
else
 if (PatioDoorSensor.state == CLOSED) {
  PatioDoorTimer.postUpdate ("OFF")
  logInfo("DOOR", "Patio Door Closed, Timer OFF")
 
  
  }
  end
2 Likes