Intersection of 2 events : find common times values

I have 2 measurments of event.
Both event will have values to 0 or 1 at different time.
Event1 is to know if my car is charging. It is 0 if not charging at time t0, 1 when charging starts then 0 at time t1. Only 2 measures for that events, begining and end.
Event2 is the car localization (home or not at home) and is recorded every 3 minutes roughly. I have tons of records.
What I am looking for is when the car is charging at home with an accuracy of +/- 3 minutes of course.

The issue :

  • impossible to have time steps aligned between the 2 measurments, then no join possible.

if mes1 start at 9:03AM and end at 11:45AM
if mes2 is 1 at 9:02 then my charging time is 11:45 - 9:03 = 2:43

is there a way to get this result with flux ?

yes, down sample using time window with the same every interval.

          |> aggregateWindow(every: 10s, fn: last, createEmpty: false)

or use truncate time column function to truncate time to the next round interval of minutes.

          |> truncateTimeColumn(unit: 10s)
1 Like