I ran into a bug (or else I'm not correct in what I want an action to do). I had a rule to control some lights and it used a rule function to generate a variable interval (an integer value) and then needed to decrement that variable as it looped. I used the set variable action to "add number", specifying -1 to decrement. This would generate an invalid number. Here is a very simplified rule (just what is needed to demonstrate the issue):

and here is the Rule Function it calls:

If I run the actions for the initial rule, it will put the result of the Rule Function call into the variable (say "1"), then when it attempts to add -1 to it, it becomes "1-1" (not 0 as would be expected when adding -1 to 1) which is not a valid number (the variable is defined as type "Number" and the Rule Function is set up to return an integer result). This leads to the error:

and the Log is:
At this point, I am unable to open the original rule as it always gives the "Unexpected Error" message. All I can do is remove that rule and recreate it.
I'm reporting this as it does not seem like it is the intended behavior. I have found that if, instead of setting my variable using "add number", I use "variable math" and subtract 1, all works as expected.


