Can someone advise how to retain the state of a contact when I am setting the state in the rules file. I will explain here what I mean. I have a Sonoff RF Bridge with Tasmota and a whole lot of different 433 MHz sensors, Water, Smoke and door sensors. Using JSONPATH I extract the ‘Data’ value from the JSON and use it in the rules file to set the state of the door. My door sensors send an OPEN and CLOSE code.
For restoring the state of items after a restart of openHAB use the persistence service with mapDB, this database is build for something like that. It holds only one value (the last) for each persisted item. Setting it up with te restoreOnStartUp policy will do the job in case of a restart.
It doesn’t help for the jetty Restarts. However those restarts sound a bit odd, you’d better solve the cause of those instead using a work-around to overcome this issue.
Although that appears to work, it is undocumented.
You should use FrontDoor.postUpdate(OPEN)
Not command - command is different from state, although it may well result in a state change eventually. And in any case you cannot send commands to a “read only” Contact type Item.
At startup, all Items are set to special state NULL, unless something else happens. That could be an update from a binding, or a rule, or as you want here, from the persistence restore action.
Items can also get set NULL when editing stuff, which is likely your other occasions.