No. Instead of using a long sleep, try something like:
Create an unbound Switch and a Rule that gets triggered when that switch is pressed.
See:
Store the value in an Item. You cannot pass parameters to Rules directly
You might find the following informative:
Note the above is a 1.x version set of rules and will need slight modifications to work in OH 2.x.
Here is an approach I wrote up a long time ago that I just rewrote as a Design Pattern which might be helpful:
And a few other comments:
- “macro” is not a term of use in the Rules DSL. We have Rules, Scripts, and lambdas. From your later posts, you seem to be referring to lambdas. Using the same terms will help us understand your questions better.
No, but unfortunately error reporting from within lambdas is not very good. Almost any error would cause that log entry. The problem could be one of syntax (I’m not sure the Rules Language supports for loops with that syntax for example). The best thing to do is load the rule up in ESH Desginer 0.8 and see if it finds any syntax errors. Then add a try catch around the entire body of your lambda and log out what exception is actually being thrown.
It does neither. It adds a lambda to the Timer thread to be executed at a later date.
That is correct. Furthermore, lambdas are only available to the rules in that .rules file.
You could pass the lambda to itself as a function argument if that is what you really wanted to do. I highly recommend applying some of what is in my links above though for a much easier and cleaner solution.
Also correct. A lambda can only access what is available from the context in which it was created. A global lambda has no context so cannot access anything except Items and what is passed to it as an argument.
Items are globally reachable. But global vals and vars are only available to Rules from within the same .rules file they are defined. And lambdas only have access to what gets passed to them.
Finally, coding rules where you need these sorts of accesses and passing of things around will only give you hours of frustration, excessively lengthy, complicated, and brittle code that is very difficult to maintain and update. I highly recommend looking through the links above and the Design Pattern examples to find alternaitve, approaches that use the features of OH and the Rules language.