Skip to content

Commit

Permalink
Merge pull request #21 from mdeweerd/skip_estimated
Browse files Browse the repository at this point in the history
Skip estimated values
  • Loading branch information
s0nik42 authored Dec 5, 2022
2 parents 41bdc5b + 30c78c1 commit c567e24
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions veolia-idf-domoticz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,15 @@ def update_device(self, csv_file):
date_time = row[0]
counter = row[1]
conso = row[2]
method = row[3] # "Mesuré" or "Estimé"

if method in ("Estimé", ):
# Do not use estimated values which may result
# in a total that is not increasing
# (when the estimated value is smaller than the
# previous real value or higher than the next
# real value)
continue

# Check line integrity (Date starting by 2 or 1)
if date[0] == "2" or date[0] == "1":
Expand Down Expand Up @@ -1203,15 +1212,34 @@ def update_device(self, csv_file):
row = rows[-1]
p_row = rows[-2]

method = row[3] # "Mesuré" or "Estimé"
if method in ("Estimé", ):
self.print( "File contains estimated data in last line: %s" % (row,))
# Try previous row which may be a measurement
row = p_row
p_row = rows[-3]

date = row[0][0:10]
date_time = row[0]
meter_total = row[1]
meter_period_total = row[2]
method = row[3] # "Mesuré" or "Estimé"

p_date_time = p_row[0]
p_meter_total = p_row[1]
p_meter_period_total = p_row[2]

if method in ("Estimé", ):
self.print( " Skip Method " + method)
# Do not use estimated values which may result
# in a total that is not increasing
# (when the estimated value is smaller than the
# previous real value or higher than the next
# real value)
raise RuntimeError(
"File contains estimated data in last lines: %s" % (row,)
)

# Check line integrity (Date starting with 2 (Year))
if date[0] == "2":
# Verify data integrity :
Expand Down

0 comments on commit c567e24

Please sign in to comment.