Water meter with ai on the edge

Hi all,

I have an esp cam with AI on the edge installed reading my analog water meter. Two days before I notice a glitch in the dashboard.
Here are my findings:
in SQLite - querying the internal HA DB - I found this:

SELECT 
datetime(created_ts,'unixepoch') as created,
datetime(start_ts,'unixepoch') as start,
state, sum
 FROM "statistics"
where metadata_id = 194
order by created_ts desc

resulting in this output (metadata_id is sensor.watermeter.value, state value is in qubic meters):

created 		        start 			        state 		sum
2025-06-13 18:00:10 	2025-06-13 17:00:00 	1001.158 	4608.343
2025-06-13 17:00:10 	2025-06-13 16:00:00 	1001.156 	4608.340999999999
2025-06-13 16:00:10 	2025-06-13 15:00:00 	1001.144 	4608.329
2025-06-13 15:00:10 	2025-06-13 14:00:00 	1001.136 	4608.321
2025-06-13 06:00:10 	2025-06-13 05:00:00 	999.99 		93.53100000000006
2025-06-13 05:00:10 	2025-06-13 04:00:00 	999.99 		93.53100000000006
2025-06-13 04:00:10 	2025-06-13 03:00:00 	999.99 		93.53100000000006
2025-06-13 03:00:10 	2025-06-13 02:00:00 	999.99 		93.53100000000006
2025-06-13 02:00:10 	2025-06-13 01:00:00 	999.99 		93.53100000000006
2025-06-13 01:00:10 	2025-06-13 00:00:00 	999.99 		93.53100000000006
2025-06-13 00:00:10 	2025-06-12 23:00:00 	999.99 		93.53100000000006
2025-06-12 23:00:10 	2025-06-12 22:00:00 	999.99 		93.53100000000006

Once the state flipped from 3 to 4 digits it seems to have a glitch in building the sum, resulting in this output on the enery dashboard:


Is there a chance of a bug? Did I do something wrong in the configuration?
Thanks for any hint.

Best,
MikeE

Can you get a dump of that entity’s recorder history from 05:00:00 to 15:00:00?

Is there a reason why there’s a big time gap there?

Hi,
the gap between happened because the water meter did not recognise the numbers correctly. There were some “negative reads” on the ESP, this is why the gap shows.
Thanks,
Mike

That’s probably where your error is coming from. You’ll need to sanitize the data a bit before the statistics gets hold of it or it will generate bogus results.