Track last update time of sensors, preferably without explicit rule for each

I’ve got a bunch of battery based sensors (xiaomi temperature) that I don’t trust their battery monitoring. So was to implement some sort if check that if no temp posted in greater than 12 hours, to alert me it probable needs a new battery.

Now I know for each item I can create a date time item with it and a rule that on every change update date time item…I do this already on a couple of dht12 sensors…but this strikes me as inelegant.

With persistence I know that can be set up on a group…they already go off to influxdb, so it would make sense to try and pull it from there. If I have to and can use mapdb I will for these items as well.


Does this mean I could grab the group of temperature sensors, and iterate over it and get the <item>.lastUpdate and check it against a predetermined time and alert off that?

Do you use Grafana? I found using their alerting mechanism much easier, just make sure your persistence is set to everyUpdate else if there is no temp change then it doesn’t get stored into influx and the grafana email alert will fire incorrectly.

Hmm I did not know that (and yes I do)…can grafana do anything cooler than email? mqtt/rest call?

That would be a good logical place to handle this functionality

Possibly, never looked beyond email as this was enough to alert me that one of my zwave devices had not reported for 2 hours.

Make a one-ruleto-to-timestamp-them-all, using Group. Add any Item to a Group, create a DateTime Item for each with an associated name, like someSensor_timestamp.

You probably want to persist the timestamps, and restore on startup. But this method does not otherwise persistence.

I think I like the grafana method…So I’ve added an alert for that…and I’ve just shut down one of my temperature sensors to see what happens…hopefully it picks it up.

I’ve also asked grafana for a feature request to add mqtt as a notification option.

How have you got this set up?
Are you running a query for each, it a manual query for each access? Or using a regex to select all the series?

And how is the alert set up?

One for the temperature item for each of my sensors, checks (every 30 min to reduce load) if no data for 2 hours

Ahh right, and your metrics are set up like this?

Slightly different, as you get some smoother looking graphs with fill(linear)

You also need to add your smtp stuff to /etc/grafana/grafana.ini and setup your default notification channel

Not sure if you got this working but I found this while researching tidying up my persistence, examples at the bottom and seems simple enough and can send to mqtt.

Yeah I did get it working, but I might look at the rule option as well. Only because grafana does pushover and slack.

Also its not very flexible on that you have to query each thing individually. And while it works, something that just iterates over a group would be preferred