Alert on any items in a Group not being updated e.g. within last 24hrs

Hi all,
i’m on Pi4 with Openhab4.1 most recent final release.

I have several sensors like Lora via TTN(MQTT) and quite a bunch of zigbee2mqtt sensors delivering a very decent level of “security” in my household, especially the water leak sensors help a lot and did alerady save me twice with a broken water pipe…

what happens not that often but it does that at some point of this MQTT play something crashes and sensors do not deliver any more data.

Therefore i’m looking for a way to get informed if a single sensor out of like 40 items did not update within the last 24hours. Of course i already do “expire” for some items, but its not the way to go foward and i hoped that there is a way to use the item group function.

If there is a solution/piece of rules code available that works similar to my idea, i’m very happy to continue/finalize it for my situation. Many many Thanks in advance.
Norbert

btw. i’m using InfluxDB for my persistence data storage.

I’d think that expire is the most straight forward way of doing this.

You could check persistence but it’s more complicated than using expire.

You can use the availability feature if zigbee2mqtt , so that your related things will go offline after some time.

You can then trigger rules based on thing status

@JimT Thanks for your reply. my concern is that when using like 50 timers for such sensors (even if i only use a single parameter sent into an item of these sensors) it will be a load of timers to check for the overall system. Or am i wrong and thats what its built for and even 500 would not be an issue at all?

Thanks

@Matze0211 did never use/know about availability in z2m. but still i would not cover arround 50% of my sensors that come via TTN-network and simple MQTT messages.

I’m not sure I’d be worried about 50 expires (timers) but I understand your concern.

To do it using a rule, assuming you have them in a group and set up persistence

Using JRuby rule file:

every :minute do
  FreshnessCheckGroup.members.select { |sensor| sensor.state? && sensor.last_update < 24.hours.ago }.update(NULL)
end

You can also send yourself an email, or sound an alert through a speaker using TTS listing the names of all the stale items etc if you prefer.

@JimT

Thanks for the jruby example for a group of items.

I never did the ruby extension, and would try to sail arround this additional construction site.
Is there another way to use all sensors in a group and have a similar functionality?

Maybe a way to check each item within the group on an update to UNDEF…(from Expire)

rule "Expire Group - Notification"
when
    Member of ExpireAlert received update......
then

Kind Regards.
Norbert

I thought you wanted to avoid using expire?

Thanks for your reply.

Sorry, i did not check that the Ruby-script also does take care of the Expire part. i tought this script would “just” simplify the centralized “alarming”.

I’m really grateful for your idea about ruby scripting. I rather would go with Expire for now to not have another script engine running on my machine in addition to learning how to handle it.

Maybe you know if this works “stable”. My idea is to check if an update is done to UNDEF…and then trigger.
But how would i write this…received update to UNDEF …or …changed to UNDEF ?

rule "Expire Group - Notification"
when
    Member of ExpireAlert received update......
then

The Ruby example can be written in rulesdsl too. Just a bit more painfully.

Changed should be fine.