Display time since last update

Posted on
Sat Jul 14, 2018 4:19 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

Display time since last update

Anyone have any clever ideas of how to show times of last updates for a set of devices? In my case, I'm trying to do this for a set of battery-operated devices (motion sensors) that don't reliably report battery level.

I've was messing around trying to use using grafana template variables to auto-create a bunch of singlestat panels, and using the "time of last point" stat option from single stat, with units of date & time > from now. This sort of works. I can get it to display times like "15 minutes ago". However, I ran into problems of not being able to use any value mappings. The still bigger problem is that it seemed that Grafana Home Dashboard has a "minimum update frequency" setting that was making it so the timestamp of the last update was different from the last time Indigo actually received an update from the device.

So I could try setting minimum update frequency to zero, but I suspect that will probably come back to bite me by breaking some of my other graphs.

In Indigo, I can see that the "Last Updated" field has the data I'm interested in, but when I use Plugins>Grafana Home Dashboard>Explore Device this field doesn't even show up, so I presume it is handled "specially" by the plugin. Conceptually, I can see why it might have been omitted - it shouldn't really be needed. So I supposed I could try

I'm hoping others may have some clever ideas.

Posted on
Sun Jul 15, 2018 1:27 pm
vtmikel offline
Posts: 642
Joined: Aug 31, 2012
Location: Boston, MA

Re: Display time since last update

Hi there-

I'm surprised to learn that the last updated property does not make it into Influx. I could look into this. This is the part of the plugin that I inherited and has not been touched by me in any significant way.

Two clever ways you could accomplish this-

1. Dont use Influx. Influx is a time series database. It's actually kind of silly to put a timestamp into a time series database anyway. If you use PostgreSQL for your Indigo history, you could have Grafana query that. If you use the built-in DB it wont be possible to query that since it doesnt have a server you can point Grafana to.

2. Use a variable. You could update the variable when a update comes in, keeping track of the Last Update via your own means.

If my plugin could send the Last Updated to Influx, the minimum update frequency would not disrupt your results. The minimum update frequency is there to send repetitive updates to Influx so that your graphs are complete. It would not change the data in any way.

Let me know where you land, perhaps others will have a better solution. If you want me to put it on the list to add the Last Updated field to the available properties, I'll look into it.

Posted on
Sun Jul 15, 2018 2:52 pm
dduff617 offline
Posts: 659
Joined: Jul 05, 2006
Location: Massachusetts, USA

Re: Display time since last update

I added lastChanged to the "include specific states" list in GHD configuration and now I'm seeing that field. That improved things considerably.

Now I can use singlestat panels to display the value. As a metric, I use datasource: indigo, from device_changes where name = /^$motionsensor$/ select lastChanged last() math(* 1000) group by tag(name) alias by $tag_name. I use the "from now" unit selection option for the singlestat, which converts a date/time value into a string like "16 minutes ago".

The "math(* 1000)" is to convert the numerical date value used by indigo to that recognized by grafana. I used the template variable $motionsensor as a template variable using query "show tag values from device_changes with key = "name"" and filtered it with a regex /.* Motion$/ (which works for my naming conventions) to limit it to motion my insteon motion sensors.

For the singlestat panel, I use the option "repeat for each value of" and use my template variable $motionsensor. This way, from a pulldown menu at the top of the panel, I can select any of my motion sensors (or all of them) and I will get an array of singlestats, each showing the time

The result is an array of boxes on my panel that have the device name and the time since last update for each motion sensor.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest