How to make a piston make a decision at the end of a timer


#1

Hello,

I am trying to have a piston make a decision after a timed wait command. Here is the basic flow.

If- location mode changes to “dusk” and “kitchen lights are 100%”, then start 2 hour timer.

When- Piston wakes up evaluate current location mode and make a decision on what level to set lights based off that.

At first I thought I could do this with restrictions, but because the piston executes top to bottom, all that happens is it evaluates the first true conditions and executes regardless of how much time is left on the timer.

Any thoughts on what I could do?


#2

First thing I can think of is make it Execute a secondary piston that is not subscribed to events that will evaluate your location mode.


#3

OK so there are a couple of things to watch out for.

Firstly the piston will be fired whenever the location mode changes. If the wait is part of the then block it the wake up will be cancelled unless the TCP is set to Never Cancel.

If it isn’t part of the then block it will be replaced by a new wait so you’d need to manipulate the length of the wait to be two hours from when the change to dusk happened.

Secondly, if the piston was fired because it received a location mode event, the value in the event will be considered the current value for the duration of the execution of the piston. That includes waking up after a wait. So that makes the suggestion from @eibyer rather attractive.