[wiki] Getting Started with OH3: rewriting the tutorial - 9. Make everything work together: rules (advanced)

What do you think: Will this work with an operator as well?

No. To support something like that you need to use a condition (i.e. the But only if…).

Of course, the answer to your questions could also have been discovered if you had tried to run it.

As has always been the case, you can’t do math or comparisons in your rule triggers.

1 Like

For this, I would need a „previous state“ property which isn‘t available and won‘t be added according to Kai. So the only way is to solve this with scripted rules.

What do you mean? Any rule triggered by a changed trigger has the previous state in the event. You may not be able to do it just in the UI, but there is a Script Condition. In JavaScript it would be something like

event.oldState > 5

In Rules DSL it would be something like

previousState > 5

That’s it, just that one line.

So your trigger is when it changes to 0.00 (note with floating point numbers there will be times when 0.00 is really 0.00000001231234 and the rule will fail to trigger).

Your condition will be one of the two above Script Conditions.

1 Like

Rich, thank you - I’ll dig into it! Thank you for the examples and the warning regarding the float value.
Is there a simple way to circumvent the float issue?

@rlkoshak, it worked - thank you!