This piston does not seem to work.
Is it that I have 3 separate triggers in one piston
3 triggers in a row
Can you show logs?
Ok, so it’s working today
yesterday it didn’t work all day. Those logs are gone.
I’ll keep an eye on it
So I take it that I can have as many If’s and each of those can have a trigger
Would I run into problems if I had two triggers under the same if
What you are doing is pretty common and looks fine.
This can get more complex if you start putting waits into the task areas.
Doing it like this vs. 3 separate pistons at an overhead level is pretty much the same difference.
- there is a school of thought that says simple pistons, doing a single function.
So it is a design choice of smaller vs. bigger pistons.
On a single piston execution, only a single event wakes the piston for execution. So multiple triggers do not happen at the same time (they can be back to back). As far as piston programming, events are 1 at a time.
Two triggers under the same IF, connected with AND would be an issue; extremely unlikely that both triggers would be true at the same exact moment. However, two triggers connected by an OR is ok.
You can have multiple triggers on an individual if statement, as long as they are “or’d” together, rather than “and’d”. Also, you can not nest triggers within if statements, as this would be the same as an and.
Only one trigger will happen at once and start the piston, which then runs top to bottom. Only the triggering condition will evaluate as true for that execution, with any other triggers evaluating as false.
I’ve just noticed a strange behaviour with the “is now and stays” trigger, which may explain what you’ve experienced.
I created a simple piston with just one “is now and stays” trigger, saved the piston, and then noticed it didn’t seem to be triggering. The condition it was testing did not change, but I expected it to trigger after 60 secs (as specified). I then clicked test, to get the trace display, and 60 secs later it triggered. It’s worked fine since.
Thanks, guy Paul1964 that must have been my problem its working well since I hit the test earlier today
One other thing
I have an if statement
Motion is now and stays inactive for 3 min
then I set the variable to false
or an if statement
Changes to inactive
then set the variable to false
and then do wait 3 min
In the 1st example if the motion is retriggered within the 3 min then time starts again
In the second example, I’m under the assumption that it would not re-start the time and the light would turn off after 3 min
I’m trying to turn off 2 lights at different times based on the variable but if the motion is retriggered I want the timer to restart
Does that make sence
Do you want 3 separate things to happen? Or only something to happen when all 3 are true? This isn’t going to do what you think it is going to do. This will always shut off switch 6 after 2 minutes, regardless of why it was turned on. And it will always turn off switch 7, regardless of why it was turned on, not just because it was turned on by motion.
What was you expecting to trigger the piston? The way the
is now and stays works is any time it is evaluated it will test if the condition is currently true. If it is then it will then set a timer for the required period e.g. 60 seconds. It will then return false regardless and continue with the piston.
If in the next 60 seconds the piston executes again and the condition is no longer true the timer will be ‘cancelled’ (it will still happen but the piston won’t do anything when it does). Otherwise the timer will either be left alone or restarted (I forget which). The condition again returns false regardless.
When the timer event happens the piston will do nothing if the timer cancelled, but otherwise will fast forward to the
stays condition and it will return true and continue.
stays is classed as a trigger so that the piston will, by default, subscribe to the device attribute it is considering and execute when it might have changed.
Nothing happened to make the piston run until the test button was pressed. That caused the piston to execute.
Thanks for the detailed explanation, I think it makes sense to me.
I think the timer does get restarted, as my simple piston is still operating correctly, even though the condition part does change to false at some points.
I guess I was expecting WC to start the timer when the condition first changed to the “is” value. However, it sounds as though you need to start the timer by executing the piston, and after that it is always running, not just when the ”is” is true
If you turn on full logging, you should see if timers are getting cancelled.
It is one of the hazards of having multiple triggers in the same piston that task cancellation policy can affect you.
If you are trying to do a sequence, there is also the followed by operator for triggers
A further observation on this. I suspect that if you restart the hub or update webcore this piston needs another test (or execution from another trigger) to get the stays condition working again.
Looking at the log, the wait does seem to be cancelled when the condition is false. I suspect if the condition is false when the hub is restarted, the wait never gets set up. Once running, there seems to be a hidden trigger on the stays condition, which when true starts the timer. Is this something WC could set up with out the red for the piston to be manually run using test?