Rule trigger problem - changed from

I recently noticed a problem with one of my rules.

It relates to my intruder alarm so the problem could have been there for a while, given that over the last year, it’s been unusual for everybody to be out! Alternatively, it could have been introduced in the upgrade from OH2 to OH3.

When the alarm is set, the display goes blank. To detect the system being unset, I use a rule that triggers when the display changes from blank:

when Item alarmPanelDisplay changed from "                                "

I’ve had this rule for a few years but had to update it for the new Alarmdecoder binding because it handled the string slightly differently from the v1. That said, I did get it working at that stage.

The problem I have is that the rule is triggering every time the display changes, regardless of the previous state. So basically it’s doing:

when Item alarmPanelDisplay changed

which isn’t what I want. I could understand it never triggering if the handling of the string has changed but to always trigger seems odd.

Anyone else had a similar problem?

Is this a file based OH3 rule? Probably.

You might try with “double dogears” around null-string
when Item alarmPanelDisplay changed from ""

Failing that, do it longhand

when
   Item alarmPanelDisplay changed
then
   if (previousState == "") {
      // do stuff
   }

Thanks for the tip. I’ve tried a few combinations but each time I find something that doesn’t trigger on every change, it doesn’t detect the one I’m looking for either.

More testing required. Your solution of using an if statement and previous value should work but I’m going to try to find how to make changed from work before I go for that.

I don’t think we can help much without more details.
What “somethings”? Only String type Items could ever change from empty string. Don’t expect it to work with any other Item type.
The changes that you are ‘missing’ will appear in your events.log, you might compare actual changes to trigger construction.

Thanks but I wasn’t requesting any more help (yet!)

I was just acknowledging your previous help.