After writing all of the below I did the test. This will work to set an Item to empty string
Try {expire="20s,state= "}
. Note the space after the =.
You cannot send a NULL state as a command but you should be able to post it as an update.
Though there might be some logic in place that sees that it is working with a String and it always converts it to a String.
For the empty string one of these two might work
{expire="20s,state=\"\""}
{expire="20s,state=''"}
Or you can change your test in the Rule to if(KeypadBuffer.state == UNDEF)
perhaps.
Why can’t you use changing it to “@” as a flag to reset the Item to “” just like you are with NULL now?
Or submit an issue to ask for it to be added. Or even better add this support yourself and submit a PR if you are able.
I must be missing something because if you have to check for NULL anyway I fail to see how adding checks for “NULL” or “@” to the same place is any different beyond adding a couple of || clauses to the if you already have in place.
This is something I have a pet peeve with. I get annoyed when people ask for help but insist that the solution must work they way they have preconceived it to work. Your primary goal is to be able to process key presses from a keypad. Vincent’s approach only strays from the way you have pre-decided to reach that goal. You may have reasons that have not yet been communicated but so far the only reason I can discern is because you don’t want to.
It’s like asking for a hammer to drive in a screw and rejecting anyone who suggests using a screw driver. The simile is a bit extreme for this case but not in many many others who ask for help on this forum. It’s annoying and feels like a waste of time.
Unless using persistence with restoreOnStartup. Though even there, as long as we have that timing bug Rules should still deal with NULL states.
After all of this, there are at least two issues here, one probably a bug and the other probably a feature request (assuming my escaped expire strings above do not work to set it to empty string).
-
By default Expire binding should set String Items to UNDEF by default, not “UNDEF”. The NULL issue is trickier per rossko’s discussion of the purpose of NULL. It may not be appropriate for Expire to ever set an Item to NULL.
-
We should be able to use Expire to go to an empty String.