Rule that triggers when an item does not change for some time

Hi,

I want to write a rule that only triggers when an items (or several items) have not changed for a defined period of time. There does not seem to be a trigger for that. Any ideas how to achieve that with the existing possibilities?

Background: I am using the JeeLink binding. About once every 2 week the temperature values from all sensors do not update anymore and I need to restart the binding. I want to monitor the values by rule and restart the binding automatically when e.g. two values have not updated for more than 3 hours.

Thanks,
Torsten

Ok,
You can use the expire binding, start by intalling the binding and create a switch item

Switch Jeelink_Timer { expire="3h, command=OFF" } //Timer set for 3 hours

Then rules:

rule "Check JeeLink Binding"
when
    Jeelink_Item1 received update or
    Jeelink_Item2 received update
then
    Jeelink_Timer.sendCommand(ON) //start the timer
                                  // the timer will reset every time an ON command is sent to it
end

rule "JeeLink_Timer expired"
when
    Jeelink_Timer received command OFF
then
    // DO WHAT YOU WANT WHEN THE TIMER EXPIRES
    // sendMail, sendTelegram.....
end

Good luck

3 Likes

hi torsten,

I have the same problem with my jeelink. a question, how do you restart the jeelink or the binding? In FHEM you can use the following command: attr Jeelink timeout 120,30 (meaning that after 120 seconds no data, a reset is performed, check every 30 seconds), but how does that work in OH?
I also found the following post, but unfortunately there was no answer:

https://community.openhab.org/t/new-jeelink-openhab2-binding/15018/191

Thank you for your help!

Maybe you can use this:

Thanks a lot, that works well for the first rule and I think it will work for the second rule as well. Just need to setup sth to toggle restart of the binding from the command line but that should be possible.

Yes, many people seem to have that problem but there does not seem to be an “official” workaround.

Manually I restart the binding as follows:

  1. login to karaf console
  2. list all bundles with cmd “bundle:list”
  3. pick the ID of the item “JeeLink binding” from that list, say X, and enter “bundle:restart X”

Afterwards, the items will be updated correctly again.

For doing that automatically I am planning to pass the command directly to ssh when logging in to karaf console. Maybe I need to place a keyfile for login w/o password. Have not tried yet, though.