Nightmare! Stop OH2 turning on my relays

Having exorcised your ghost, it is perhaps worth now spending a little time considering why you would want to persist and restore absolutely everything.

Especially for Pi/SSD users, it generates unwanted overheads.

Restoring some sensor states is counterproductive. No good being reassured by openHAB that all doors are closed when in fact it has no idea yet.

Persisting a remote button press is a different case - but do you care what the button last pressed before reboot was?

It’s sometimes implemented as a lazy way to avoid Items being NULL or UNDEF in rules. It all depends, but rules can be rewritten to deal sensibly with ‘missing’ values and that may be more desirable than using old stale values.
Quite often there’s a bonus effect from that effort that will bring graceful responses to in-flight failures.

That’s a decision best made early in rules development. I’ve very few persisted/restored Items, and am fed up with typing
if (myItem.state != NULL && myItem.state !=UNDEF)
but I bet I get less surprises :smiley:

Changes can be quite subtle sometimes, !=ON is not the same as ==OFF for example.

Just food for thought.

That’s probably a good idea - once the button event is dealt with, clear it away.

switch-case also has a default: option, by the by,

switch (sceneNumber) {
        case 1.0 : {
            ...
            }
	default : {logInfo("myrule", "Unexpected Button!")}	
	}