Webcore "only when"

Am I doing something wrong here? I only want this piston to execute every minute, but only between sunrise and midnight, and only when HE's location mode is Home. Yet it seems to ignore the location mode.

Side question... I've never really understood the "only when" thing. Using an "if" with the same predicates would really have the same result, wouldn't it?

image

image

Full piston here:

every operation are like a 'mini piston' within a piston.

A couple suggestions

  • add an if for your restriction, and if it succeeds do the get...

  • in the webcore forum, there are a lot of good folks that may have better suggestions.

1 Like

Not sure what you mean by that. The topmost "only when" should be a conditional for the entire piston, no?

I'll post something in the WC forum. Tried here because there seems to be a lot more activity. Searching for "only when" in the WC forum yields 0 results.

Actually, I was wrong about what is happening. This piston fired off last night well AFTER midnight, so the entire "only when" conditional is being ignored.

This is described more in the webcore forum.

Normally pistons run top to bottom on every execution.

However there are exceptions for 'every' statements, which

  • when the piston runs the first time the every gets scheduled
  • later the every runs, but what runs is only the every statement (not the entire piston)

So in your case I expect what is happening, is the piston has the restriction, but the every statement does not.

Every statements are interesting, in that you can have several in a piston and they execute separately from each other but do not run the entire piston.

That does appear to be what's happening. Seems like a bug to me though.

If this is by design, then the "only when" block should not be allowed if the action is "every". Or at the very least, a message would come up and not let you save the piston.

I still don't understand why "only when" exists at all; it seems redundant since an "if" statement should be able to do the exact same thing. And in this case, it probably would have worked the way I expected. Not sure why I used "only when", I think it might just be a little easier to create a predicate that way than to create an IF and move existing actions, etc. within it.

I think you should take this up in the webcore forum.

Given on the timing fire for the every does not run the entire piston, you can see why the mainline piston restriction would not run every time.

It can be a feature or a bug depending on what one intends to do. Not using the every statement would likely make things much clearer for you.

Anyway, I suggest you have a chat with more webcore experts.

Yes. Given the special nature of "every", which I was not aware of, I suspect that the "only when" predicate is evaluated at the time the "every minute" schedule itself is set up. So if I were to edit and save the piston when the only when evaluated to false, the piston probably wouldn't be scheduled at all.

Guess it would be easy to test, but I'm just going to change it to use 'if" and get on with my life. This piston causes Alexa announcements to be made for various weather conditions, and my wife is getting tired of lightning alerts at 4am.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.