From 7dde4edf46bbed48f2e8724d002c749c9f914fa7 Mon Sep 17 00:00:00 2001 From: Julien NOEL <30711794+s0nik42@users.noreply.github.com> Date: Wed, 31 Dec 2025 17:34:57 +0100 Subject: [PATCH 1/3] Update meters_to_ha.py --- apps/meters_to_ha/meters_to_ha.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meters_to_ha/meters_to_ha.py b/apps/meters_to_ha/meters_to_ha.py index d9284bf..4c323e6 100755 --- a/apps/meters_to_ha/meters_to_ha.py +++ b/apps/meters_to_ha/meters_to_ha.py @@ -1662,8 +1662,8 @@ def get_veolia_idf_file(self): r"//span[" r"contains(text(), 'Alertes de consommation')" + r" or contains(text(), 'Contrats')" - + r" or contains(text(), 'consulter l\'historique')" - + r' or contains(translate(text(), "CLH", "clh"), "consulter l\'historique")' + + r" or contains(text(), 'consulter l')" + + r' or contains(translate(text(), "CLH", "clh"), "consulter l")' + r"]", ) ) From 6c4f46ea6d7a6b19cba5fdef8f13249ab719d391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20No=C3=ABl?= Date: Thu, 1 Jan 2026 16:50:02 +0100 Subject: [PATCH 2/3] Fix: Total counter derive --- apps/meters_to_ha/meters_to_ha.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/meters_to_ha/meters_to_ha.py b/apps/meters_to_ha/meters_to_ha.py index 4c323e6..22fee38 100755 --- a/apps/meters_to_ha/meters_to_ha.py +++ b/apps/meters_to_ha/meters_to_ha.py @@ -2613,7 +2613,6 @@ def parse_veolia_historical_data(self, csv_file, website): # Remove the first row (header) from the list that is not useful rows = rows[1:] - last_total = 0 # Set date format for service (IDF || service.eau.veolia.fr) if website == SERVICE_EAU_VEOLIA_FR: @@ -2624,10 +2623,8 @@ def parse_veolia_historical_data(self, csv_file, website): for row in rows: method = row[3] # "Mesuré" or "Estimé" if method in ("E", "Estimé"): - # Ignore estimated index (we use the last total) - meter_total = last_total + int(row[2]) - else: - meter_total = int(row[1]) + int(row[2]) + # Ignore estimated values + continue date_obj = dt.datetime.strptime(row[0], date_format) @@ -2640,11 +2637,10 @@ def parse_veolia_historical_data(self, csv_file, website): stat = { "start": date_formatted, # formatted date "state": int(row[2]), - "sum": meter_total, + "sum": int(row[1]) } # Add the stat to the array stats_array.append(stat) - last_total = meter_total self.mylog(st="OK") return stats_array From fcf8069b5eb1470e9661db2a2eaca650a4e75183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20No=C3=ABl?= Date: Thu, 1 Jan 2026 16:50:46 +0100 Subject: [PATCH 3/3] Fix: counters historical import --- apps/meters_to_ha/meters_to_ha.py | 40 +++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/apps/meters_to_ha/meters_to_ha.py b/apps/meters_to_ha/meters_to_ha.py index 22fee38..8e48c30 100755 --- a/apps/meters_to_ha/meters_to_ha.py +++ b/apps/meters_to_ha/meters_to_ha.py @@ -3082,19 +3082,51 @@ def sanity_check(self): ) def update_veolia_historical_data(self, stats_array): - # Prepare the statistics that need to be sent + # Prepare the statistics that need to be sent for _period_total + + total_stats = [ + {"start": stat["start"], "state": stat["sum"]} + for stat in stats_array + ] data = { "has_mean": False, - "has_sum": True, + "has_sum": False, "statistic_id": ( "sensor.veolia_%s_total" % self.configuration[PARAM_VEOLIA_CONTRACT] ), "unit_of_measurement": "L", "source": "recorder", - "stats": stats_array, + "stats": total_stats, } - self.mylog("Publish all the historical data in the statistics") + + self.mylog(f"Publish all the historical data in the statistics of _total sensor : {total_stats}") + self.open_url(HA_API_STATISTICS, data) + self.mylog(st="OK") + + # Prepare the statistics that need to be sent + period_stats = [ + { + "start": stat["start"], + "state": stat["state"], + "mean": stat["state"], + "min": stat["state"], + "max": stat["state"] + } + for stat in stats_array + ] + data = { + "has_mean": True, + "has_sum": False, + "statistic_id": ( + "sensor.veolia_%s_period_total" + % self.configuration[PARAM_VEOLIA_CONTRACT] + ), + "unit_of_measurement": "L", + "source": "recorder", + "stats": period_stats, + } + self.mylog(f"Publish all the historical data in the statistics of _period_total sensor : {period_stats}") self.open_url(HA_API_STATISTICS, data) self.mylog(st="OK")