"only when" ignored


#1

1) Give a description of the problem
Top level “only when” predicate is ignored. Piston runs no matter what the time is, and no matter what mode is active. “Only when” predicates seem to work as expected everywhere else.

Former ST user; I’m running WC on Hubitat but have no idea if this is an issue specific to HE or not.

image

A more general question: what is the purpose of “only when”? I could accomplish the same thing using “if” so “only when” seems redundant. A search for “only when” here turns up 0 results.

2) What is the expected behaviour?
I would expect the piston to trigger every minute, evaluate the “only when” expression(s) and exit if the “only when” evaluates to false. Or perhaps the next execution of the piston would only be scheduled for 1 minute unless the time is between midnight and sunrise, in which case the next execution would be scheduled for sunrise. Same result, different implementation.

3) What is happening/not happening?
The piston runs ever minute, regardless of time or mode

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
Will have to wait until after midnight to capture logs


#2

Timers (the every blocks) are something of a special case in webCoRE. They run outside the usual flow. So every minute the every block will run independently of the rest of the piston.


#3

Ok, but if that’s how timers work then shouldn’t the “only when” block be disallowed in that case, rather than silently failing?

What’s the difference between “if” and “only when”? I honestly don’t see any logical difference and not sure why I used “only when” instead of “if”. There must be some difference or else it has no reason to exist.


#4

I’m not entirely sure what the deal is with only when in that context as it does seem to be associated with the every block. I don’t have webCoRE installed to properly refresh my memory.

The only when conditions are a bit like preconditions in SmartThings Routines/Automations. They apply restrictions when the piston runs but don’t influence when it runs. On the other hand the triggers or conditions in if conditions are used to select which device events the piston handles, or when timed runs are scheduled.

Personally I never bothered with the only when blocks as they could get in the way somethings without really gaining anything.


#5

I prefer using the Virtual device time instead of using {$now} … but hey, that’s my preference!