Item x changed from more than X to less than Y?

Openhab 3.4.1

Whats the easy way to trigger when an item changes from more than X to less than Y?

this seems overcomplicated for something that should be a oneliner in “when”

rule "Power Sensor Change"
    Item powersensor changed
    if ((powersensor.previousState() as Number) > 10 && (powersensor.state as Number) < 5) {
        // do something here


@rlkoshak posted this article on hysteresis that could be of interest for you.

1 Like

Note, if this Item is linked to a Channel, the hysteresis profile might be a more appropriate way to achieve this.

1 Like