I think my problem was trying to do your shortened version more explicitly… So was still think that either the string is “-” or it isn’t.
Have used you shortened version and it is great.
I didn’t see where this specific statement was address in the thread. That is not correct. A Timer runs in the background, it does not tie up a rule thread. It sits quietly in the background until the scheduled time comes to run the passed in lambda.
So if the reason for changing is you are afraid of long running rules, you’ve nothing to fear. Timers exist to avoid tying up a thread waiting around doing nothing.
Rich, I was hoping you’d be curious enough to investigate “expire to empty string”. (We did flush all this out for OH2)
I suspect it is a UI limitation, and directly editing expire metadata to state:"" will work.
But it is a different expire implementation in OH3, and the lesson may have been forgotten.
I brought it up on the PR where Expire was added to the core and was under the impression that it was added. But I never tested it. If it’s not working perhaps an issue should be filled. My understanding was it was supposed to be possible.
I’m a little short on time theses days (lots of personal stuff) and it’s challenging to even keep up with the forum. So I really can’t sign myself up for a looking deep into stuff like this right now.
It is possible to get an empty string through the expire metadata, but you have to use the “send command” version and not the “update state” version. I don’t think it’s the UI but how the metadata is interpreted by the core. If the update state option is selected, the format of the expire metadata is:
value: time,new state
If it’s just value: time or if it is value: time, this is interpreted as an absence of value and UNDEF is the resultant state.
If the send command option is used the format of the metadata is:
value: time,command=new state
But here if the command is blank after the = you actually get an empty string as the value. Here are the logs from an example value: 0h0m5s,command=
2021-05-01 17:31:45.338 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Expire_Test' received command Test
2021-05-01 17:31:45.339 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Expire_Test' changed from UNDEF to Test
2021-05-01 17:31:50.698 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Expire_Test' received command
2021-05-01 17:31:50.698 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Expire_Test' changed from Test to
One thing to be sure to look at is how the metadata is rendered in the UI, in the code tab, and how it’s rendered in the JSON itself. There might be some translation issues going on with empty strings between the three that is causing problems. I know that with widgets I think the UI treats empty string to mean “use the default” and it actually doesn’t save/render the empty string. That’s why (I think) you have to use " " in the State Description metadata to suppress the printing of the Item’s state when it’s rendered in a List Item Widget.