Can't use OR when checking two lists of devices and saving them to lists


#1

For the record, I rewrote this piston and it’s working fine, but I was kinda disappointed that this manner didn’t work. I was just curious if this was normal behavior for the code.

1) Give a description of the problem

This piston checks for open doors and outdoor lights that are on. The piston should state if doors are open (save devices to list) OR lights are on (save devices to list). However, it only works with an AND.

2) What is the expected behaviour?

If doors are open, the piston will create a list of open doors. If outdoor lights are on, it will create a list of outdoor lights that are on.

3) What is happening/not happening?

The piston only works with AND, which could presumably cause a problem if all doors are closed but an outdoor light is on. Basically, if a door is open, it skips over the second OR line.

**4) Post a Green Snapshot of the piston![image|45x37]

If anyone’s curious, here’s the new version:


#2

Yes, webCoRE calls that a Condition Traversal Optimization. As soon as any condition in an OR is true, or any condition in an AND is false, the result of the condition group is known so there is no need to evaluate the remaining conditions in the group. If you delve into the piston settings you will see you can opt to disable this behaviour when you need all the conditions to be evaluated.


#3

Thank you…I figured there had to be a reason. Always learning something new about WC, lol

Though I find it weird…you’d think the opposite would be the default, since it’s an OR statement.


#4

Just a guess but maybe the intention is to make webcore do the least amount of work which is why the optimizations are enabled by default.