[Solved] Mean Sensor Value by time stamp over historical period


Hi all, just after some advice / direction:

I have a flow meter reporting state to losant every 15 minutes. I am trying to compare each new reading with a running average of the same sensor data in the past X days which occured at the same time of day. Just wondering the best way to go about this in a workflow.

An example would be:

  • a flow of say 20 liters is reported at 12:01 pm 24th November.
  • I then want to retrieve the flow that was reported on the same device with the same hour/minute timestamp (12:01) for the past 10 days, average that result and compare it to the new reported flow.

Going around in circles on how to retrieve the historical info by hour:minute and average it… Any help much appreciated.



This will be a little complicated, but doable with a series of Gauge Query nodes. The Gauge Query allows you to query specific data from the past.

In the above screenshot, I’m querying data that was reported exactly 24 hours ago. The input supports negative times, which represent the past relative to now.

So to get the last three values reported at the same time of day as now, you’d use three gauge query nodes with the Range End set to:

  1. -86400000
  2. -172800000
  3. -259200000

86400000 is 24 hours in milliseconds. So that’s 86400000 * 1, 86400000 * 2, 86400000 * 3, etc.

You can put this in a Loop Node to make changing the number of days and aggregating the results pretty easy.

Play with this concept and see if that works for you. I’d be happy to create an example workflow if you’re having difficulty implementing this approach.



Works perfectly! As you suggested I manipulated the Range End using the loop index * -86400000, as such can change the number of days to retrieve. Thanks for the help!

1 Like


Excellent! That’s the exact loop implementation I would have recommended. Glad you got it figured out!

1 Like