I'm hoping to get some advice on how to best get the pressure data for a simple barometer trend line. I want to get pressure values from now, 3 hours ago and 6 hours ago and see two ways to do that:
1. Call SensorHistory.getPressureHistory() with a duration of 6 hours, iterate through the result using next() and take the 1st data value, the first one that is at least 3 hours old, and the last one. Assuming there is one sample taken every 1-2 minutes, then 6 hours would result in a dataset with 180-360 samples.
2. Call SensorHistory.getPressureHistory() three times - once with :period => 1 and then with a period of 3hrs and 6hrs and ordered oldest first - and take the data value from the first sample of each returned SensorHistoryIterator object.
The second one seems straightforward to code but which approach is more efficient (or is there another better way to do this)?
And are there any pitfalls I need to watch out for, other than that not all devices have a pressure history, any sample data may be null and there may not be 6 hours of data available?