Then I have a rule which changes this holder to ON when there is a motion like so
rule "Motion activity"
when
Member of gMotion received update
then
var now = new DateTimeType()
postUpdate(triggeringItem.name+"_t", now.toString)
postUpdate(gMotion_t, now.toString)
if(triggeringItem.state == ON){
postUpdate(holderMotionPresence,ON)
}
end
But OH does not update ON to ON if that state was before, so expiry is running from first trigger but not from the last one.
How I can re-trigger ON eg. reset expiration timer on EACH triggering.state == ON ?
Do I need to toggle ON/OFF ? (which is weird way) or there is something else I can do?
this is not about single motion detector (which are operated by mqtt on/off not by expiry)
but this is helper global, which should hold presence information (part of it)
I do have group:switch indeed as well, but I want different item to hold this information for me for various reasons.
As far as I know the only way te retrigger the expire binding is let it recieve a ‘new’ ON command. So you will need to toggle something to create a state change from OFF to ON.
Every time an expire binding item receives any other command other then the command in the expire configuration (in this case command=OFF) the expire time is reset
maybe try sendCommand instead of postUpdate
from the docs
The expiration time will be started or restarted every time an item receives an update or command other than the specified “expire” update/command.
Any future expiring update or command is cancelled if the item receives an update or command that matches the “expire” update/command.
It does, but updates that don’t produce a change are not usually logged in events.log (just to reduce clutter).
You don’t need sendCommand to restart expire timing.
If you don’t believe that, that you can create a simple rule triggered on updated that logs out state. Unfortunately, implicit previousState is not available where there wasn’t actually a change, but looking at a few runs should convince.
There is a completely different question about whether bindings pass a device update to openHAB when there is no change. Generally they do, but this is binding specific.
Here is a demonstration of postUpdate working with expire binding, as documented.
Whatever you thought your problem was, had some other cause.
Switch testSw "slide me" {expire="2m, command=OFF"}
var counter = 0
rule "test expire begin"
when
System started or
Item testSw changed to OFF // expire completed
then
// begin timing
testSw.postUpdate(ON)
logInfo("test", "postUpdate begins timing")
end
rule "test expire announce"
when
Item testSw received command OFF
then
logInfo("test", "Item has expired")
end
rule "test expire restart"
when
Time cron "0 0/1 * * * ?" // every minute
then
if (counter > 5 && counter < 10) {
// block expire for 5 mins
testSw.postUpdate(ON)
logInfo("test", "postUpdate restarts timing")
} else {
logInfo("test", "expire timing allowed")
}
counter = counter + 1
end