mirror of
https://github.com/skaringa/water-counter.git
synced 2024-11-22 09:24:24 +01:00
Pause detection fixed (again)
This commit is contained in:
parent
99c57b9c19
commit
a3a76dc7e1
@ -11,6 +11,7 @@ import os
|
|||||||
import csv
|
import csv
|
||||||
import rrdtool as rrd
|
import rrdtool as rrd
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import time
|
||||||
from math import *
|
from math import *
|
||||||
|
|
||||||
# Path to RRD with counter values
|
# Path to RRD with counter values
|
||||||
@ -58,7 +59,7 @@ def detect_pauses(data):
|
|||||||
result = []
|
result = []
|
||||||
(start_time, start_counter) = data[0]
|
(start_time, start_counter) = data[0]
|
||||||
(end_time, end_counter) = data[-1]
|
(end_time, end_counter) = data[-1]
|
||||||
data.append((end_time + 1, end_counter + 1)) # ensure that counter increments
|
data.append((time.time(), end_counter + 1)) # ensure that counter increments
|
||||||
for (ts, counter) in data:
|
for (ts, counter) in data:
|
||||||
if counter > start_counter:
|
if counter > start_counter:
|
||||||
duration = ts - start_time
|
duration = ts - start_time
|
||||||
|
Loading…
Reference in New Issue
Block a user