Calculating average motion event activation durations


#1

1) Give a description of the problem
i am trying to record and calculate the average time that motion alerts remain active.
I can record the number of activations (count) and duration of a motion alert (elapsed) but I am struggling to record the total elapsed time. I have defined local variables to record the activation count, the elapsed time of the latest activation but struggling to record the total ongoing elapsed time.
time start;
time elapsed;
int count;

record $now at event activation -
set variable {start} = {$now};

Then when event has finished -
set variable {count} = {count + 1};
set variable {elapsed} = {$now - start};

Then I want to add the elapsed to a running total variable.
set variable {total} = {total + elapsed}; but this doesnt work due to type issues

An error occurred while executing the event: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Date(java.lang.Double)

I am doing this so I can set the delay to the average, wait {total / count};

What type do I need to define to store the total running elapsed time?
Suggestions are welcomed on this…

2) What is the expected behavior?
(PUT YOUR INFO HERE)

3) What is happening/not happening?
(PUT YOUR INFO HERE)

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I made this a while back… same principle