New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Processing order of rule actions combined with 'and' is not guaranteed #531
Comments
Nope its 2 commands running at the same time. |
We've 3 options here:
I've to think about what would be the best. Comments? |
I'd prefer "and then", this looks more natural and in the overview of rules you can see whether an And will run in parallel or sequential. It's also more flexible, for example
Based on this example i think that "and then" should have higher precedence than "and" |
I would prefer a strict left to right processing and I think parallel processing is not necessary. |
I have 4 lights in my living room and they are all turning on from left to right. trigger: if woonkamer is turned on then turn light1 on and turn light2 on and turn light3 on and turn light4 on |
Look at this experiment. The rule is
Now change the variable $new from lets say 10 to 15. $old might be 10. The result is What a novice user (like me) not knows is the concurrent processing model.
which gives the right result: The result is fine . But the naturalness of the rule syntax becomes worse. |
I ran into the same problem. I also like "and then". |
I am also in favor of this, however, option "1" may be a lot easier to implement. I think it can be done simply by replacing the line https://github.com/pimatic/pimatic/blob/master/lib/rules.coffee#L871 in
At the end of the for loop the return statement in line https://github.com/pimatic/pimatic/blob/master/lib/rules.coffee#L894 needs to be replaced with the following:
I'll give it a try later and report back. I'll also make an imapct review. If the suggested change works as expected it could be ellaborated to provide for option "2". My question is when and if "parallel" execution is really required. It should also be said that execution is not really done in "parallel", but it more of an interwoven execution of asynchronous functions which belong to different execution contexts of the list of actions. To me this makes not much sense and I don't see any benefits in doing so. As @sweebee pointed out a sequence of switch actions won't result in switching on all the lights at the same time. Any views on this? @sweetpi What's your view on this? |
@mwittig I think we should implement option "1" as you suggested, so that left to right is the default. We could then add an checkbox in the rule or a keyword for parallel execution later (if necessary) Would you implement the suggested change? |
@sweetpi yes, will do |
Sometimes the first action is first and sometimes the second:
Example:
... then switch Timer off and switch Timer on
To avoid this random behaviour I use a explicit delay:
... then switch Timer off and switch Timer on after 1 second
What I expect is a left to right processing.
The text was updated successfully, but these errors were encountered: