In OH2, Expire is an installable add-on binding. I can’t believe you haven’t used it before, though.
I think you’re on the wrong track here though, why doesn’t your device report its status usefully seems to be the root question?
For the rule -
First up there is a simple syntax error.
if(Gate_partial.state = ON){
Nope, you want to test, not set it equal to.
if(Gate_partial.state == ON){
This is doomed to failure. Commands are not states. Consider a Rollerblind, where command can be UP but state 25%. It’s not as obvious with a Switch where there are commands ON and state ON, but they are not the same.
Okay, so this rule triggers on command. The command will also poke the real device, and also openHABs autoupdate feature, and sooner or later one of those will probably update the Item to state ON. It takes time. It’s there in your log extract, 9mS
Meantime, your rule running in parallel gets the Item state - the old state, before the command has taken effect.
If you want instead to know what the command was, use recievedCommand
instead of Item state.
Alternatively, if you want to respond to state change rather than command, do so by choosing a rule trigger changed
.
Unrelated, but remember also that newly initialised Items may have state NULL. One weird trick -
if(Gate_partial.state != OFF){
works if it is not-OFF, i.e. either ON or NULL
Finally
Gate_partial.sendCommand(OFF)
if it worked, this is going to send another command over zwave to your device. Is that going to happy with different commands in quick succession? I don’t know. But you don’t need to do it, you said the device is set up to auto-off itself like a pushbutton.
If you just want to update the OH Item, then just update the OH Item.
Gate_partial.postUpdate(OFF)