Need some advice and I cannot be the only one who has faced this issue.
I have a device that monitors a pump and counts the number of minutes it has pumped each day. It reports this number every hour and - importantly - the data is transmitted and recorded by Ubidots within about 5 seconds. At midnight, the pump minutes count is reset and we begin the next day’s count. The pump only pumps every 2-3 days in the winter.
The issue comes when I run the reports for the week. I use the Ubidots reports engine and report the “Max” count for a “1 day” period. The issue is that, this can lead to misleading reporting as the count for day 1 - say 50 - is counted as the “max” for day 1 as expected but also as the “max” for day 2 since it was received by Ubidots at 5 seconds after midnight. This is not correct.
I am not sure how best to correct this as I want to keep my code simple and I want to use the standard Ubidots reporting tool.
- I could zero the count after the 2300 period but this would not be correct if there is pumping activity after midnight
- I could start the reporting process before the top of the hour but this makes the code more complex as I cannot always predict cellular connection / reporting times.
- I could manually fix this issue but, in the summer when the pump can go every day, this would be hard to spot.
Any best practices or advice?