Calculate X number of Events in a 24hr period

Greetings. Was looking around the forums, but was able to find only 1 conversation back in 2019 close to my question, but not clear still. So, here it goes…

Trying to figure out the best and most logical way to calculate the number of times an event triggers from a sensor (say, ON msgs/payloads) within a day.

So, for example, I have a device that alerts ON about 25 times a day (almost exactly once every hour, with a bit more…). I can graph that ON/OFF in a 24hr dash graph, but would also like to add a saved value of whatever that ON event triggered (which I have a separate numeric attribute for) and come up with a total after 24 hrs (call it 24hr_metric_value for example), so I can, also, display the 24hr_metric_value with an indicator dash block . Makes sense?

I’m thinking data/time node with some logic, counters, maybe latch node as well, etc but would like your opinion first before delving into it. As always, thx :red_circle:

If the ON/OFF value is stored on the device as an attribute, I think you may be able to get what you’re after using the Time At Value data aggregation method. So, given a duration of 24 hours, run a gauge query with a “Time At Value” aggregation method targeting the value of “ON”. What you’ll get back is the time, in milliseconds, that the value of that particular attribute was “ON” over that 24-hour period.

Let me know if I’m off-base with what you’re after, and if so, I’ll see if I can come up with another suggestion.

1 Like

@Dylan_Schuster , thank you - yes, the ON/OFF value is stored on the device as an attributed. Let me ‘play’ with this a bit and I’ll let you know if it works/not/get stucked for more info, :red_circle: