Rules based on items staying at a certain state for an amount of time

I would like to create some rules based on items staying at a certain value for a certain time.

E.g. to turn OFF TV if no interaction was done.
Or to help automating motion sensing / presence.

I do NOT want to use a createTimer and then an IF statement because this would only momentarily check an item state.

Is there any solution for this?

have a look at the expire-binding:
https://docs.openhab.org/addons/bindings/expire1/readme.html

You’d have to Setup a Proxy switch item (e.g. Use of television), which gets set to ON, everytime you interact. after your expire time, if the item gets an automatic OFF from the binding, you can Switch off the TV.

That’s interesting, will need to look into that.

But wouldn’t it be great to that in a rule? Something like:

rule "Test"
when
    Item Test is OFF since 30 minutes
then
    sendCommand(LampDimmer, 0)
end

nope. this won’t work - the rule-engine needs some distinct event for two reasons:

  1. it uses way less memory and CPU
  2. it’s getting way more complicated for the developers and for us users.

So - the expire-binding is what you want - trust me! :wink:

rule "Test"
when
    Item ProxyTV changed to OFF
then
    sendCommand(TVItem, OFF)
end

So, if your ProxyTV item receives the OFF-command - your TVItem will also be OFF. Now you have to write some rule(s) for updating the ProxyTV item, everytime you interact with your TV. everytime an item receives an command, the expire-trigger will be reset.