In my city the Water utility uses water meters that once a day transmit their measurement.
They have a website where one can consult water consumption, weekly / daily .
Doing some digging somebody figured out how to access the API endpoint and wrote a script in php, and posted it on github. I adapted it to python, and now I can get the meter values but there is a problem, the last sensor value in the list is always 2 days old. E.g. I need to wait until August 30 to query the value of the sensor as of August 28.
Question is, is there a way to have a Utility Meter (daily) sensor
accept values that are two days old?
In the below example I queried values for the last 7 days.
The utility API returns seven entries but the last two contain no meter values.
So I need a way to tell the Utility Meter that for which day the value I got is. I need it get a sample every 24h and insert it in the db as the value that corresponds to (now()-48h)
For now I took the lazy man approach and created a REST sensor: ‘sensor.water_meter_two_days_ago’, you get the concept. It’s kind of horrible but it’s something.
Here’s a JSON example (snippet)
'intervalList': [{'intStartDate': '2021-08-23 00:00:00', 'intConsumptionTotal': 0.5, 'intConsumptionMin': 0.0, 'intConsumptionMax': 0.5, 'intervalCount': 4, 'lastReadValue': '00915.0', 'intConsumptionAvg': 0.125, 'synthesisFlag': 'A', 'intDOWAvg': 0.8333, 'lastReadDateTime': '2021-08-23 19:30:00'}, {'intStartDate': '2021-08-24 00:00:00', 'intConsumptionTotal': 0.5, 'intConsumptionMin': 0.0, 'intConsumptionMax': 0.5, 'intervalCount': 4, 'lastReadValue': '00915.5', 'intConsumptionAvg': 0.125, 'synthesisFlag': 'A', 'intDOWAvg': 0.75, 'lastReadDateTime': '2021-08-24 20:00:00'}, {'intStartDate': '2021-08-25 00:00:00', 'intConsumptionTotal': 0.0, 'intConsumptionMin': 0.0, 'intConsumptionMax': 0.0, 'intervalCount': 4, 'lastReadValue': '00916.0', 'intConsumptionAvg': 0.0, 'synthesisFlag': 'A', 'intDOWAvg': 0.75, 'lastReadDateTime': '2021-08-25 20:30:00'}, {'intStartDate': '2021-08-26 00:00:00', 'intConsumptionTotal': 0.5, 'intConsumptionMin': 0.0, 'intConsumptionMax': 0.5, 'intervalCount': 4, 'lastReadValue': '00916.5', 'intConsumptionAvg': 0.125, 'synthesisFlag': 'A', 'intDOWAvg': 0.5, 'lastReadDateTime': '2021-08-26 21:00:00'}, {'intStartDate': '2021-08-27 00:00:00', 'intConsumptionTotal': 1.5, 'intConsumptionMin': 0.0, 'intConsumptionMax': 1.0, 'intervalCount': 4, 'lastReadValue': '00918.0', 'intConsumptionAvg': 0.375, 'synthesisFlag': 'A', 'intDOWAvg': 1.1667, 'lastReadDateTime': '2021-08-27 21:30:00'}, {'intStartDate': '2021-08-28 00:00:00', 'intConsumptionTotal': 0.0, 'intConsumptionMin': 0.0, 'intConsumptionMax': 0.0, 'intervalCount': 2, 'lastReadValue': '00918.0', 'intConsumptionAvg': 0.0, 'synthesisFlag': 'A', 'intDOWAvg': 1.3334, 'lastReadDateTime': '2021-08-28 09:45:00'}, {'intStartDate': '2021-08-29 00:00:00', 'intDOWAvg': 0.75}, {'intStartDate': '2021-08-30 00:00:00', 'intDOWAvg': 0.8333}], 'unitOfMeasure': 'm3', 'intervalType': 'DAY', 'consumptionTotal': 3.0, 'consumptionAvg': 0.38, 'consumptionMax': 1.5, 'consumptionMin': 0.0}],